Web Unlocker
SERP API
Scraping Browser
Web Scraper IDE
Browser Extension
Bright Shield
Code Examples
Bright Data’s Scraping Browser supports a wide range of programming languages and libraries. We currently have full native support for Node.js and Python using puppeteer, playwright, and selenium, and other languages can be integrated as well using the other libraries below, giving you the flexibility to integrate Scraping Browser right into your current tech stack.
Language/Platform | puppeteer | playwright | selenium |
---|---|---|---|
Python | pyppeteer | playwright-python | Selenium WebDriver |
JS / Node | Native support | Native support | WebDriverJS |
Ruby | Puppeteer-Ruby | playwright-ruby-client | Selenium WebDriver for Ruby |
C# | .NET: Puppeteer Sharp | Playwright for .NET | Selenium WebDriver for .NET |
Java | Puppeteer Java | Playwright for Java | Native support |
Go | chromedp | playwright-go | Selenium WebDriver for Go |
const page = await browser.newPage();
await page.goto('https://example.com');
const html = await page.content();
For more info: https://pptr.dev/api/puppeteer.page.content
// node.js puppeteer
const page = await page.newPage();
await page.goto('https://example.com');
await page.click('a[href]');
For more info: https://pptr.dev/api/puppeteer.page.click
You might need to scroll the viewport to the bottom at times, such as when activating ‘infinite scroll’. Here’s how:
// node.js puppeteer
const page = await page.newPage();
await page.goto('https://example.com');
await page.evaluate(()=>window.scrollBy(0, window.innerHeight));
// More info at https://pptr.dev/api/puppeteer.page.screenshot
await page.screenshot({ path: 'screenshot.png', fullPage: true });
When running the example scripts above the screenshot above will be saved as “screenshot.png” within your files.
Please note that this is supported for KYC-approved customers only.
const page = await browser.newPage();
await page.setCookie({name: 'LANG', value: 'en-US', domain: 'example.com'});
await page.goto('https://example.com');
For more info: https://pptr.dev/api/puppeteer.page.setcookie
It is possible to block endpoints that are not required to save bandwidth. See an example of this below:
// connect to a remote browser...
const blockedUrls = ['*doubleclick.net*'];
const page = await browser.newPage();
const client = await page.target().createCDPSession();
await client.send('Network.enable');
await client.send('Network.setBlockedURLs', {urls: blockedUrls});
await page.goto('https://washingtonpost.com');
When using the Scraping Browser, the same country-targeting parameter is available to use as in our other proxy products.
When setting up your script, add the -country
flag, after your “USER” credentials within the Bright Data endpoint, followed by the 2-letter ISO code for that country.
const SBR_WS_ENDPOINT = `wss://${USER-country-us:PASS}@brd.superproxy.io:9222`;
In the example above, we added -country-us
to the Bright Data endpoint within our script, so our request will originate from the United States (“us”).
EU region
You can target the entire European Union region in the same manner as “Country” above by adding “eu” after “country” in your request: -country-eu
Requests sent using -country-eu
, will use IPs from one of the countries below which are included automatically within “eu”:
AL, AZ, KG, BA, UZ, BI, XK, SM, DE, AT, CH, UK, GB, IE, IM, FR, ES, NL, IT, PT, BE, AD, MT, MC, MA, LU, TN, DZ, GI, LI, SE, DK, FI, NO, AX, IS, GG, JE, EU, GL, VA, FX, FO
The allocation of a country within the EU is random.