Pyppeteer (Python) - UNMAINTAINED
We suggest not using this library anymore as it is now unmaintained, please consider playwright-python as an alternative
Connect your Python automation to Browserless using Pyppeteer, an unofficial Python port of Puppeteer.
- A Browserless API token from your account dashboard
- Pyppeteer installed (
pip install pyppeteer)
Basic Usage
import asyncio
import pyppeteer
async def main():
browser = await pyppeteer.launcher.connect(
browserWSEndpoint='wss://production-sfo.browserless.io?token=YOUR_API_TOKEN_HERE'
)
page = await browser.newPage()
url = "https://www.example.com"
await page.goto(url)
values = await page.evaluate('''() => document.querySelector('h1').innerHTML
''')
print(values)
await browser.close()
asyncio.get_event_loop().run_until_complete(main())
This example navigates to a URL and returns the page's h1 content.
For connection URL options and query parameters, see the connection URL patterns reference. If you need help getting your API token, see API key management.
FAQ & Troubleshooting
Why am I getting a 403 Forbidden error?
Your API token is missing or expired. Pass it as a ?token= query parameter in the WebSocket or HTTP URL. Verify the token in your account dashboard.
My script works locally but fails on Browserless
Local browser settings may differ from the Browserless environment. Use launch parameters to match your local setup (viewport, user agent, timezone). See launch parameters for the full list.