Companion scripts for the Solve CAPTCHAs with Puppeteer & Playwright video.
These scripts demonstrate how to detect and solve reCAPTCHA v2 challenges using Browserless's stealth endpoint with residential proxies. Three approaches are included:
captcha-puppeteer.js— Manual flow with Puppeteer. Listens forBrowserless.captchaFoundand triggersBrowserless.solveCaptchaon demand.captcha-playwright.js— Same manual flow as above, but using Playwright'sconnectOverCDP.captcha-puppeteer-auto.js— Automatic flow with Puppeteer. AddssolveCaptchas=trueto the connection URL so Browserless solves CAPTCHAs automatically; the script just listens forBrowserless.captchaAutoSolved.
- Node.js v18+
- A Browserless API token
npm install
mkdir -p screenshotsOpen each script and replace YOUR_API_TOKEN_HERE with your Browserless API token:
const token = "YOUR_API_TOKEN_HERE";npm run puppeteer # manual solve, Puppeteer
npm run playwright # manual solve, Playwright
npm run auto # automatic solve, PuppeteerEach script navigates to the 2captcha reCAPTCHA v2 demo, solves the challenge, clicks the "Check" button, and saves a screenshot to ./screenshots/screenshot.png.
/stealthendpoint — Browserless stealth browser with anti-bot measuresproxy=residential&proxyCountry=us— Routes through a residential US proxy (often required for reCAPTCHA to behave naturally)Browserless.captchaFound— CDP event fired when a CAPTCHA is detected on the pageBrowserless.solveCaptcha— CDP command that triggers the solversolveCaptchas=true— Connection-string flag that enables automatic solving; pair with theBrowserless.captchaAutoSolvedevent