Playwright Proxy Integration with Bright Data

Learn how to setup your Playwright proxy settings and integrate with Bright Data’s Proxy IPs

Playwright is a Node.js library to automate Chromium, Firefox, and WebKit with a single API and we will cover all the required steps for a successful Playwright integration with Bright Data. Start using rotating proxies to enhance your Playwright proxies and avoid getting blocked.

New Bright Data product: Scraping Browser

Playwright Compatible
Easily make an API call to fetch any number of browser sessions and interact with them using Puppeteer (Python) or Playwright (Node.js) over a CDP protocol. Ideal for scraping projects that require website interactions to retrieve data, like hovering over a page, clicking buttons, scrolling, adding text, etc.

Bright Data Super Proxy and Playwright Integration

  • Begin by going to your Bright Data Dashboard and clicking ‘create a Zone’.
  • Choose ‘Network type’ and click save.
  • Within Playwright fill in the ‘Proxy IP:Port’ in the ‘server’ value, for examplehttp://zproxy.lum-superproxy.io:22225.
  • Under ‘username’ input your Bright Data account ID and proxy Zone name, for example:lum-customer-CUSTOMER-zone-YOURZONE and under ‘password’ put your Zone password found in the Zone settings.
  • For example:
const playwright = require('playwright');

(async () => {
    for (const browserType of ['chromium', 'firefox', 'webkit']) {
        const browser = await playwright[browserType].launch({
            headless: false,
            proxy: {
                server: 'http://zproxy.lum-superproxy.io:22225',
                username: 'lum-customer-USERNAME-zone-YOURZONE',
                password: 'PASSWORD'
            },
        });
        const context = await browser.newContext();
        const page = await context.newPage();
        await page.goto('http://lumtest.com/myip.json');
        await page.screenshot({ path: 'example.png' });
        await browser.close();
    }
})();

Proxy Manager and Playwright Integration

  • Create a Zone with the network, IP type, and number of IPs you wish to use.
  • Install the Proxy Manager.
  • Click ‘add new proxy’ and choose the Zone and settings you require, click ‘save’.
  • In Playwright, under the ‘server’, input your local IP and Proxy Manager port (i.e. 127.0.0.1:24000)
    • The local host IP is 127.0.0.1
    • The port created in the Proxy Manager is 24XXX. For example, 24000
  • Leave the username and password values empty, as the Bright Data Proxy Manager has already been authenticated with the Super Proxy.
  • For example:
const playwright = require('playwright');

(async () => {
    for (const browserType of ['chromium', 'firefox', 'webkit']) {
        const browser = await playwright[browserType].launch({
            headless: false,
            proxy: {
                server: '127.0.0.1:24000',
                username: '',
                password: ''
            },
        });
        const context = await browser.newContext();
        const page = await context.newPage();
        await page.goto('http://lumtest.com/myip.json');
        await page.screenshot({ path: 'example.png' });
        await browser.close();
    }
})();