Puppeteer is a powerful Node.js library for controlling headless Chrome. When combined with DataSea proxies, you can scrape JavaScript-rendered content at scale, rotate IPs to avoid detection, and access geo-restricted websites.
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
# With geo-targeting (add to username)
username_country-UnitedStates
username_country-GB
username_session-abc123Install Puppeteer using npm or yarn.
# Using npm
npm install puppeteer
# Using yarn
yarn add puppeteer
# For lighter installation (uses system Chrome)
npm install puppeteer-coreConfigure Puppeteer to use DataSea proxy with authentication.
const puppeteer = require('puppeteer');
const PROXY_HOST = 'pr.datasea.io';
const PROXY_PORT = '7011';
const PROXY_USER = 'your_username';
const PROXY_PASS = 'your_password';
(async () => {
// Launch browser with proxy
const browser = await puppeteer.launch({
args: [
`--proxy-server=http://${PROXY_HOST}:${PROXY_PORT}`
],
headless: true
});
const page = await browser.newPage();
// Authenticate with proxy
await page.authenticate({
username: PROXY_USER,
password: PROXY_PASS
});
// Navigate to a page
await page.goto('https://httpbin.org/ip');
// Get the content
const content = await page.content();
console.log(content);
await browser.close();
})();Verify the proxy is working by checking your IP address.
const puppeteer = require('puppeteer');
async function testProxy() {
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011'],
headless: true
});
const page = await browser.newPage();
await page.authenticate({
username: 'your_username',
password: 'your_password'
});
await page.goto('https://api.ipify.org?format=json');
const ipData = await page.evaluate(() => {
return JSON.parse(document.body.innerText);
});
console.log('Proxy IP:', ipData.ip);
await browser.close();
}
testProxy();Access 195+ countries with residential, datacenter, ISP, and mobile proxies.
Rotate IPs per request or maintain sticky sessions for multi-page scraping.
Scrape dynamic content that requires JavaScript execution.
Puppeteer's page.authenticate() works seamlessly with DataSea proxies.
Track proxy usage and success rates in your dashboard.
Residential proxies see fewer blocks and CAPTCHAs than datacenter IPs.
Scrape single-page applications and sites that require JavaScript rendering.
const puppeteer = require('puppeteer');
async function scrapeSPA() {
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011'],
headless: true
});
const page = await browser.newPage();
await page.authenticate({
username: 'your_username',
password: 'your_password'
});
// Wait for dynamic content to load
await page.goto('https://example.com/spa', {
waitUntil: 'networkidle2'
});
// Wait for specific element
await page.waitForSelector('.product-list');
// Extract data
const products = await page.evaluate(() => {
return Array.from(document.querySelectorAll('.product')).map(el => ({
name: el.querySelector('.name')?.textContent,
price: el.querySelector('.price')?.textContent
}));
});
console.log(products);
await browser.close();
}
scrapeSPA();Access region-specific content by targeting specific countries.
const puppeteer = require('puppeteer');
async function geoTargetedScrape(country) {
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011'],
headless: true
});
const page = await browser.newPage();
// Add country to username for geo-targeting
await page.authenticate({
username: `your_username_country-${country}`,
password: 'your_password'
});
await page.goto('https://example.com/localized-content');
const content = await page.evaluate(() => document.body.innerText);
console.log(`Content from ${country}:`, content);
await browser.close();
}
// Scrape from different countries
['US', 'GB', 'DE', 'JP'].forEach(country => {
geoTargetedScrape(country);
});Maintain the same IP throughout login and authenticated browsing.
const puppeteer = require('puppeteer');
async function authenticatedScrape() {
const SESSION_ID = 'login' + Date.now(); // 1-32 letters or digits
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011'],
headless: true
});
const page = await browser.newPage();
// Use sticky session for consistent IP
await page.authenticate({
username: `your_username_country-UnitedStates_session-${SESSION_ID}`,
password: 'your_password'
});
// Login
await page.goto('https://example.com/login');
await page.type('#username', 'myuser');
await page.type('#password', 'mypass');
await page.click('#login-button');
// Wait for redirect
await page.waitForNavigation();
// Browse authenticated pages with same IP
await page.goto('https://example.com/dashboard');
const data = await page.evaluate(() => document.body.innerText);
console.log('Dashboard data:', data);
await browser.close();
}
authenticatedScrape();Capture how websites appear to users in different countries.
const puppeteer = require('puppeteer');
const fs = require('fs');
async function screenshotFromCountry(country, url) {
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011'],
headless: true
});
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.authenticate({
username: `your_username_country-${country}`,
password: 'your_password'
});
await page.goto(url, { waitUntil: 'networkidle2' });
await page.screenshot({
path: `screenshot-${country}.png`,
fullPage: true
});
console.log(`Screenshot saved for ${country}`);
await browser.close();
}
// Capture from multiple countries
const countries = ['US', 'GB', 'DE', 'FR', 'JP'];
const url = 'https://example.com';
Promise.all(countries.map(c => screenshotFromCountry(c, url)));Solution: Verify your proxy credentials and ensure you're using the correct port (7011).
// Correct proxy configuration
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011'], // Port 7011
headless: true
});
// Don't forget authentication
await page.authenticate({
username: 'your_username',
password: 'your_password'
});Solution: Increase timeout and use appropriate waitUntil option.
// Increase timeout
await page.goto('https://example.com', {
timeout: 60000, // 60 seconds
waitUntil: 'domcontentloaded' // or 'networkidle2'
});
// Set default timeout for all operations
page.setDefaultTimeout(60000);
page.setDefaultNavigationTimeout(60000);Solution: Use residential proxies and realistic browser settings. DataSea does not solve CAPTCHAs or bypass anti-bot systems.
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011'],
headless: true
});
const page = await browser.newPage();
// Use residential proxy for better success
await page.authenticate({
username: 'your_username_country-UnitedStates',
password: 'your_password'
});
// Set realistic viewport and user agent
await page.setViewport({ width: 1920, height: 1080 });
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');Solution: Close pages after use and limit concurrent pages.
// Process URLs in batches
async function scrapeWithLimit(urls, concurrency = 5) {
const browser = await puppeteer.launch({
args: ['--proxy-server=http://pr.datasea.io:7011']
});
for (let i = 0; i < urls.length; i += concurrency) {
const batch = urls.slice(i, i + concurrency);
await Promise.all(batch.map(async (url) => {
const page = await browser.newPage();
await page.authenticate({
username: 'your_username',
password: 'your_password'
});
try {
await page.goto(url);
// Process page...
} finally {
await page.close(); // Always close pages
}
}));
}
await browser.close();
}Connect to 150M+ real IPs in seconds. Built for scale, privacy, and performance. Free trial available.