Playwright is Microsoft's modern browser automation library with native proxy support. It provides a clean API for proxy configuration with authentication, making it ideal for web scraping and testing across multiple browsers.
Sign in to your DataSea dashboard and copy your proxy credentials.
# DataSea Proxy Configuration
Proxy Host: pr.datasea.io
HTTP Port: 7011 (for http:// and https:// websites)
HTTPS-to-proxy Port: 7010 (TLS between your client and the proxy)
# Your credentials
Username: your_proxy_username
Password: your_16_char_password
# Geo-targeting (add to username)
username_country-UnitedStates
username_session-abc123
username_country-UnitedStates_session-abc123Install Playwright and browser binaries.
# Install Playwright
npm install playwright
# Install browsers
npx playwright install
# Or install specific browser
npx playwright install chromiumPlaywright has built-in proxy support with authentication - no plugins needed.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({
proxy: {
server: 'http://pr.datasea.io:7011',
username: 'your_username',
password: 'your_password'
}
});
const page = await browser.newPage();
await page.goto('https://httpbin.org/ip');
const content = await page.textContent('body');
console.log('Proxy IP:', content);
await browser.close();
})();Verify the proxy is working correctly.
const { chromium } = require('playwright');
async function testProxy() {
const browser = await chromium.launch({
proxy: {
server: 'http://pr.datasea.io:7011',
username: 'your_username',
password: 'your_password'
}
});
const page = await browser.newPage();
await page.goto('https://api.ipify.org?format=json');
const ipData = await page.evaluate(() => JSON.parse(document.body.innerText));
console.log('Proxy IP:', ipData.ip);
console.log('Proxy is working!');
await browser.close();
}
testProxy();Access 195+ countries with residential, datacenter, ISP, and mobile proxies.
Get new IPs per request or maintain sticky sessions across pages.
Same proxy config works with Chromium, Firefox, and WebKit.
Built-in proxy configuration with authentication - no extra plugins.
Use different proxies per browser context for parallel scraping.
Target specific countries using username parameters.
Test your scraping across different browser engines.
const { chromium, firefox, webkit } = require('playwright');
const proxyConfig = {
server: 'http://pr.datasea.io:7011',
username: 'your_username',
password: 'your_password'
};
async function scrapeWithBrowser(browserType, name) {
const browser = await browserType.launch({ proxy: proxyConfig });
const page = await browser.newPage();
await page.goto('https://example.com');
const title = await page.title();
console.log(`${name}: ${title}`);
await browser.close();
}
// Test across all browsers
Promise.all([
scrapeWithBrowser(chromium, 'Chromium'),
scrapeWithBrowser(firefox, 'Firefox'),
scrapeWithBrowser(webkit, 'WebKit')
]);Access region-specific content from different countries.
const { chromium } = require('playwright');
async function scrapeFromCountry(country) {
const browser = await chromium.launch({
proxy: {
server: 'http://pr.datasea.io:7011',
username: `your_username_country-${country}`,
password: 'your_password'
}
});
const page = await browser.newPage();
await page.goto('https://example.com/localized');
const content = await page.textContent('body');
console.log(`Content from ${country}:`, content.slice(0, 200));
await browser.close();
}
// Scrape from multiple countries
const countries = ['US', 'GB', 'DE', 'JP', 'AU'];
Promise.all(countries.map(scrapeFromCountry));Use browser contexts to scrape multiple sites with different proxies.
const { chromium } = require('playwright');
async function parallelScrape(urls) {
const browser = await chromium.launch();
const results = await Promise.all(urls.map(async (url, index) => {
// Each context gets a different proxy/session
const context = await browser.newContext({
proxy: {
server: 'http://pr.datasea.io:7011',
username: `your_username_session-ctx${index}`,
password: 'your_password'
}
});
const page = await context.newPage();
await page.goto(url);
const title = await page.title();
await context.close();
return { url, title };
}));
await browser.close();
return results;
}
const urls = [
'https://example1.com',
'https://example2.com',
'https://example3.com'
];
parallelScrape(urls).then(console.log);Login and scrape with sticky sessions to maintain the same IP.
const { chromium } = require('playwright');
async function authenticatedScrape() {
const SESSION_ID = 'login' + Date.now(); // 1-32 letters or digits
const browser = await chromium.launch({
proxy: {
server: 'http://pr.datasea.io:7011',
username: `your_username_country-UnitedStates_session-${SESSION_ID}`,
password: 'your_password'
}
});
const context = await browser.newContext();
const page = await context.newPage();
// Login
await page.goto('https://example.com/login');
await page.fill('#email', 'user@example.com');
await page.fill('#password', 'password123');
await page.click('button[type="submit"]');
// Wait for navigation
await page.waitForURL('**/dashboard');
// Scrape authenticated content
const userData = await page.textContent('.user-info');
console.log('User data:', userData);
// Save session for later
await context.storageState({ path: 'auth.json' });
await browser.close();
}
authenticatedScrape();Solution: Verify your credentials are correct and the username format is valid.
// Correct proxy configuration
const browser = await chromium.launch({
proxy: {
server: 'http://pr.datasea.io:7011', // Use port 7011
username: 'your_username', // Or with targeting: username_country-UnitedStates
password: 'your_password' // 16-character password from dashboard
}
});Solution: Increase timeout and use appropriate wait conditions.
// Increase navigation timeout
await page.goto('https://example.com', {
timeout: 60000, // 60 seconds
waitUntil: 'domcontentloaded'
});
// Or set default timeout for all operations
page.setDefaultTimeout(60000);
// Wait for specific element instead of full load
await page.goto('https://example.com');
await page.waitForSelector('.content', { timeout: 30000 });Solution: Create new contexts for different proxies, or use rotating proxies.
// Option 1: New context per proxy
async function withDifferentProxy(country) {
const context = await browser.newContext({
proxy: {
server: 'http://pr.datasea.io:7011',
username: `your_username_country-${country}`,
password: 'your_password'
}
});
return context.newPage();
}
// Option 2: Rotating proxy (new IP each request)
// Just use base username - IPs rotate automatically
const context = await browser.newContext({
proxy: {
server: 'http://pr.datasea.io:7011',
username: 'your_username', // No session = new IP each request
password: 'your_password'
}
});Solution: Use residential proxies and configure realistic browser settings.
const context = await browser.newContext({
proxy: {
server: 'http://pr.datasea.io:7011',
username: 'your_username_country-UnitedStates', // Use residential proxies
password: 'your_password'
},
// Realistic browser fingerprint
viewport: { width: 1920, height: 1080 },
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
locale: 'en-US',
timezoneId: 'America/New_York',
// Disable automation flags
javaScriptEnabled: true,
});
// Add random delays between actions
await page.waitForTimeout(Math.random() * 2000 + 1000);Connect to 150M+ real IPs in seconds. Built for scale, privacy, and performance. Free trial available.