Appearance
Usage
The core pattern is always the same: connect to Bright Data's remote browser via a WebSocket CDP URL, then drive it exactly like a local browser.
Playwright (Node.js)
javascript
const playwright = require('playwright');
const AUTH = 'brd-customer-CUSTOMER_ID-zone-ZONE_NAME:PASSWORD';
const TARGET_URL = 'https://example.com';
async function main() {
const browser = await playwright.chromium.connectOverCDP(
`wss://${AUTH}@brd.superproxy.io:9222`
);
const page = await browser.newPage();
await page.goto(TARGET_URL);
console.log(await page.content());
await page.screenshot({ path: 'screenshot.png', fullPage: true });
await browser.close();
}
main().catch(console.error);Puppeteer (Node.js)
javascript
const puppeteer = require('puppeteer-core');
const AUTH = 'brd-customer-CUSTOMER_ID-zone-ZONE_NAME:PASSWORD';
const TARGET_URL = 'https://example.com';
async function main() {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://${AUTH}@brd.superproxy.io:9222`
});
const page = await browser.newPage();
await page.goto(TARGET_URL);
console.log(await page.content());
await page.screenshot({ path: 'screenshot.png', fullPage: true });
await browser.close();
}
main().catch(console.error);Selenium (Python)
python
from selenium.webdriver import Remote, ChromeOptions
AUTH = 'brd-customer-CUSTOMER_ID-zone-ZONE_NAME:PASSWORD'
SBR_WEBDRIVER = f'https://{AUTH}@brd.superproxy.io:9515'
options = ChromeOptions()
driver = Remote(command_executor=SBR_WEBDRIVER, options=options)
try:
driver.get('https://example.com')
print(driver.title)
finally:
driver.quit()CAPTCHA Handling (Playwright)
Bright Data exposes a custom CDP command Captcha.waitForSolve for waiting on automatic CAPTCHA resolution:
javascript
const client = await page.context().newCDPSession(page);
await client.send('Captcha.waitForSolve', { detectTimeout: 10000 });
console.log('CAPTCHA solved');Bandwidth Optimization
Block images, fonts, and media to reduce GB usage:
javascript
await page.route('**/*.{png,jpg,jpeg,gif,webp,svg,woff,woff2,ttf,mp4,mp3}', route => route.abort());Notes
- Replace
CUSTOMER_ID,ZONE_NAME, andPASSWORDwith your real credentials from the Bright Data Control Panel. - The default timeout for page operations should be set to at least 120 seconds to account for CAPTCHA solving time.
- Each
browser.close()ends the remote session. Sessions are billed by bandwidth consumed, not by open time.