Standard CDP Functions
Explore essential CDP functions for Browser API, from setting cookies to country targeting. Learn to optimize web scraping with these common Puppeteer and Playwright commands.
Browser API supports CDP so all puppeteer functions/features work within our browsers. You can find all puppeteer API documentation and usage examples on the official puppeteer documentation page. We have also added a few Bright Data-specific custom CDP events which can be useful as well.
The following are a few common browser navigation functions to get you started.
Get Page HTML
Get Page HTML
For more info: https://pptr.dev/api/puppeteer.page.content
Click on element
Click on element
For more info: https://pptr.dev/api/puppeteer.page.click
Scroll to page bottom
Scroll to page bottom
You might need to scroll the viewport to the bottom at times, such as when activating ‘infinite scroll’. Here’s how:
Take Screenshot
Take Screenshot
When running the example scripts above the screenshot above will be saved as “screenshot.png” within your files.
Set Cookies
Set Cookies
Blocking Endpoints
Blocking Endpoints
It is possible to block endpoints that are not required to save bandwidth. See an example of this below:
Country Targeting
Country Targeting
When using the Browser API, 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.
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”:
The allocation of a country within the EU is random.