Runnable code examples for common Browserless use cases.
-
Get an API token: sign up at browserless.io and grab your token from the account dashboard.
-
Clone this repo
git clone https://github.com/browserless/examples.git cd examples -
Pick an example: browse the Use cases table below and open the folder for the task you want to run (e.g.
examples/take-a-screenshot). -
Set your token: replace
YOUR_API_TOKEN_HEREin the script with your actual API token. -
Run it: each example folder contains ready-to-run scripts. For example, to take a screenshot with cURL:
bash examples/take-a-screenshot/rest/curl/screenshot.sh
Or with Node.js:
node examples/take-a-screenshot/frameworks/puppeteer/screenshot.mjs
Each example is self-contained. No shared dependencies to install.
| Use case | Description | Languages | Frameworks |
|---|---|---|---|
| Auto-Accept Cookie Consent Banners | Detect and dismiss cookie consent banners before scraping or capturing a page | ||
| Basic Playwright Connection | Connect an existing Playwright script to Browserless by swapping chromium.launch() for connectOverCDP() |
||
| Browse Cloudflare Access-Protected Pages | Access pages protected by Cloudflare Access zero-trust policies using Service Token headers or a saved authenticated profile | ||
| Run Concurrent Browser Sessions | Launch multiple independent browser sessions in parallel to speed up large-scale scraping or automation | ||
| Extract and Download Images | Find all images on a page and download them to disk, including JS-rendered content | ||
| Fill and Submit a Form | Automate form interactions — typing into fields, selecting options, solving CAPTCHAs, and clicking submit | ||
| Generate a PDF | Export any webpage or HTML content as a PDF using the Browserless PDF API | ||
| Log In and Reuse Sessions | Log in once and reuse that authenticated state across many browser sessions without re-entering credentials | ||
| Log In via Email OTP | Automate login flows that send a one-time passcode to an email address — trigger the OTP, read the code, and enter it | ||
| Log In with BQL and Browser Automation | Automate a login flow — filling credentials, solving CAPTCHAs, and handling post-login redirects | ||
| Record a Browser Session | Capture a browser session as a .webm video file using the Browserless recording API |
||
| Save Logins to Authenticated Profiles | Capture a logged-in browser state once and reuse it across parallel sessions without re-entering credentials | ||
| Solving Cloudflare Challenges | Bypass Cloudflare Turnstile and JS challenges using the /unblock endpoint or BQL's solve mutation |
||
| Solving reCAPTCHAs | Automatically detect and solve reCAPTCHA v2, v3, invisible, and other CAPTCHA challenges during browser automation | ||
| Take a Screenshot | Capture any webpage as a PNG or JPEG using the Browserless screenshot API |