Skip to main content
Version: v2

Solving Captchas

note

Looking for full developer docs? See them here. This feature is only available on the Scale plan and Enterprise plans.

Some sites won't allow you to bypass their captchas or strictly enforce them to be solved on some sites. You can solve these captchas with Browserless without much effort. You can have a listener waiting to see if a captcha is found and you can also solve them programmatically.

Every captcha you solve costs 10 units from your plan.

Find a captcha programmatically

You can listen for captchas on the site, in puppeteer it would be like this:

const cdp = await page.createCDPSession();
await new Promise((resolve) =>
cdp.on('Browserless.captchaFound', () => {
console.log('Found a captcha!');
return resolve();
}),
);

Solve a captcha programmatically

You can solve the captcha from code, in puppeteer it would be like this:

const cdp = await page.createCDPSession();
const { solved, error } = await cdp.send('Browserless.solveCaptcha');
console.log({
solved,
error,
});

Complete sample

Here's a sample snippet you can run to demonstrate this works.

import puppeteer from 'puppeteer-core';

// Recaptcha
(async () => {
const browser = await puppeteer.connect({
browserWSEndpoint:
'wss://production-sfo.browserless.io/chromium/stealth?token=YOUR-API-TOKEN&timeout=300000',
});

const page = await browser.newPage();
const cdp = await page.createCDPSession();

await page.goto('https://www.google.com/recaptcha/api2/demo', {
waitUntil: 'networkidle0',
});

await new Promise((resolve) =>
cdp.on('Browserless.captchaFound', () => {
console.log('Found a captcha!');
return resolve();
}),
);

const { solved, error } = await cdp.send('Browserless.solveCaptcha');
console.log({
solved,
error,
});

// Continue...
await page.click('#recaptcha-demo-submit');
})().catch((e) => {
console.error(e);
process.exit(1);
});