Skip to main content
Version: v1

Python (Playwright)

We support playwrightfor Python out of the box via their playwright.chromium().connect_over_cdp method.

Here's a simple snippet of its implementation, we can add additional features through the context, such as a proxy, shown below as well, feel free to remove that if you're not going to use one.

Find more of the playwright documentation for python here.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
browser = p.chromium.connect_over_cdp('wss://chrome.browserless.io?token=your_token')
context = browser.new_context()
page = context.new_page()
page.goto('http://www.example.com',wait_until='domcontentloaded')
print(page.content())
context.close()

Built-in proxy

Use our in-built residential proxies seamlessly, which will consume units from your subscription, more info here. Your connection would look like this

  browser = p.chromium.connect_over_cdp('wss://chrome.browserless.io?token=your_token&proxy=residential&proxySticky&proxyCountry=us')

You can set your IP address to be geolocated in a specific country with the &proxyCountry flag.

Third party proxies

If you want to bring your own third party proxy, add these parameters to the new_context as shown below.

  context = browser.new_context(
proxy={"server": "http://proxyprovider.com:porthere", "username": "yourusername", "password": "yourpassword"}
)