How do I integrate Bright Data into a web browser automation tool?

Integrating Bright Data into a web browser automation tool such as Selenium or Puppeteer can be done by route to Bright Data super proxy port which isbrd.superproxy.io:22225 and authenticate with your Bright Data Zone credentials.
The username and password of the specific Zone can be find in the API examples.
Watch Bright Data Browser Automation webinar
Integrating Bright Data super proxy with Selenium:

const {Builder, By, Key, until} = require('selenium-webdriver');
const proxy = require('selenium-webdriver/proxy');

(async function example(){
    let driver = await new Builder().forBrowser('firefox').setProxy(proxy.manual({
        http: 'brd.superproxy.io:22225',
        https: 'brd.superproxy.io:22225'
    })).build()

    try {
        await driver.get('http://lumtest.com/myip.json');
        driver.switchTo().alert().sendKeys('brd-customer-USERNAME'+Key.TAB+'PASSWORD');
        driver.switchTo().alert().accept();
    } finally {
        await driver.quit();
    }
})();

NOTE: The latest FireFox version that supports the above code is 66.0.5. Newer versions support IP:PORT format, so using newer FireFox versions can be done through Proxy Manager configuration.


Integrating Bright Data super proxy with Puppeteer:

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({
        headless: false,
        args: ['--proxy-server=brd.superproxy.io:22225']
    });
    const page = await browser.newPage();
    await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36');
    await page.authenticate({
        username: 'brd-customer-USERNAME',
        password: 'PASSWORD'
    });
    await page.goto('http://lumtest.com/myip.json');
    await page.screenshot({path: 'example.png'});
    await browser.close();
})();

Watch video: connecting Puppeteer with Bright Data super proxy
Note: Chromium user-agent include "HeadlessChrome" that need to be replaced as shown in the example above using setUserAgent.

Was this article helpful?