Skip to content

Usage

All examples below connect to Bright Data's remote Chromium fleet. Replace the credential placeholders with your actual Browser API zone credentials.

Puppeteer (Node.js)

Minimal working script that navigates to a URL, prints the rendered HTML, and saves a screenshot.

bash
npm install puppeteer-core
javascript
#!/usr/bin/env node
const puppeteer = require('puppeteer-core');

const AUTH = `${process.env.BRD_USERNAME}:${process.env.BRD_PASSWORD}`;
const TARGET_URL = 'https://quotes.toscrape.com/js/';

async function main() {
  console.log('Connecting to BrowserAI...');
  const browser = await puppeteer.connect({
    browserWSEndpoint: `wss://${AUTH}@brd.superproxy.io:9222`,
  });

  const page = await browser.newPage();
  await page.goto(TARGET_URL, { timeout: 120_000 });

  const html = await page.content();
  console.log(html.slice(0, 500));

  await page.screenshot({ path: 'screenshot.png', fullPage: true });
  console.log('Done. screenshot.png written.');

  await browser.close();
}

main().catch(console.error);

Playwright (Node.js)

bash
npm install playwright
javascript
const { chromium } = require('playwright');

const AUTH = `${process.env.BRD_USERNAME}:${process.env.BRD_PASSWORD}`;
const TARGET_URL = 'https://quotes.toscrape.com/js/';

(async () => {
  const browser = await chromium.connectOverCDP(
    `wss://${AUTH}@brd.superproxy.io:9222`
  );
  const page = await browser.newPage();
  await page.goto(TARGET_URL, { timeout: 120_000 });
  console.log(await page.title());
  await browser.close();
})();

Selenium (Python)

bash
pip install selenium
python
from selenium.webdriver import Remote, ChromeOptions
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
import os

AUTH = f"{os.environ['BRD_USERNAME']}:{os.environ['BRD_PASSWORD']}"
SERVER = f"https://{AUTH}@brd.superproxy.io:9515"
TARGET_URL = "https://quotes.toscrape.com/js/"

connection = ChromiumRemoteConnection(SERVER, "goog", "chrome")
driver = Remote(connection, options=ChromeOptions())
driver.get(TARGET_URL)
print(driver.title)
driver.quit()

Geolocation targeting

Add the country parameter to the username to pin the session to a specific country:

brd-customer-CUSTOMER_ID-zone-ZONE_NAME-country-us

For city-level targeting, append -city-dallas (city slug, lowercase, no spaces).

Notes

  • The default session timeout is 2 minutes. Adjust via the timeout option in page.goto.
  • Each navigation event consumes bandwidth billed against your zone plan.
  • CAPTCHA solving and bot-detection bypass are automatic; no extra configuration is needed.
  • The Browser API Playground at docs.brightdata.com lets you run ad-hoc sessions in the browser without writing code.