Why use proxies with Puppeteer?

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.

Prerequisites

  • Node.js 14 or higher installed
  • npm or yarn package manager
  • DataSea account with proxy credentials
  • Basic JavaScript/Node.js knowledge

Setup guide

  1. 01

    Get your DataSea credentials

    Sign in to your DataSea dashboard and copy your proxy credentials.

    text
    # 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-abc123
  2. 02

    Install Puppeteer

    Install Puppeteer using npm or yarn.

    bash
    # Using npm
    npm install puppeteer
    
    # Using yarn
    yarn add puppeteer
    
    # For lighter installation (uses system Chrome)
    npm install puppeteer-core
  3. 03

    Basic proxy setup

    Configure Puppeteer to use DataSea proxy with authentication.

    javascript
    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();
    })();
  4. 04

    Test your connection

    Verify the proxy is working by checking your IP address.

    javascript
    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();

Key features

Global coverage

Access 195+ countries with residential, datacenter, ISP, and mobile proxies.

Automatic rotation

Rotate IPs per request or maintain sticky sessions for multi-page scraping.

JavaScript rendering

Scrape dynamic content that requires JavaScript execution.

Built-in authentication

Puppeteer's page.authenticate() works seamlessly with DataSea proxies.

Real-time monitoring

Track proxy usage and success rates in your dashboard.

Fewer blocks

Residential proxies see fewer blocks and CAPTCHAs than datacenter IPs.

Common use cases

Scraping JavaScript-heavy websites

Scrape single-page applications and sites that require JavaScript rendering.

javascript
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();

Geo-targeted browsing

Access region-specific content by targeting specific countries.

javascript
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);
});

Sticky sessions for login flows

Maintain the same IP throughout login and authenticated browsing.

javascript
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();

Taking screenshots from different locations

Capture how websites appear to users in different countries.

javascript
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)));

Troubleshooting

ERR_PROXY_CONNECTION_FAILED

Solution: Verify your proxy credentials and ensure you're using the correct port (7011).

javascript
// 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'
});

Timeout on page.goto()

Solution: Increase timeout and use appropriate waitUntil option.

javascript
// 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);

Frequent blocks

Solution: Use residential proxies and realistic browser settings. DataSea does not solve CAPTCHAs or bypass anti-bot systems.

javascript
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');

Memory Issues with Multiple Pages

Solution: Close pages after use and limit concurrent pages.

javascript
// 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();
}

Get started with industry‑leading proxy access

Connect to 150M+ real IPs in seconds. Built for scale, privacy, and performance. Free trial available.