CDP API

Scrapeless Scraping Browser extends the standard CDP (Chrome DevTools Protocol) functionality with a series of powerful custom functions to enhance browser automation capabilities. This documentation primarily covers CDP functions related to CAPTCHA handling.

Captcha Solver Features

Feature Overview

Scraping Browser includes advanced CAPTCHA solution capabilities that can automatically handle mainstream CAPTCHA types appearing on web pages.

Supported CAPTCHA Types

  • reCaptcha
  • Cloudflare Turnstile

Event Monitoring Mechanism

Core Events

Scraping Browser provides three core events to monitor the CAPTCHA solving process:

Event NameDescription
Captcha.detectedCAPTCHA detected
Captcha.solveFinishedCAPTCHA solved
Captcha.solveFailedCAPTCHA solve failed

Event Response Data Structure

FieldTypeDescription
typestringCAPTCHA type: recaptcha turnstile
successbooleanSolution result
messagestringStatus message: "NOT_DETECTED" "SOLVE_FINISHED" "SOLVE_FAILED" "INVALID"
token?stringToken returned on success (optional)

Implementation Examples

// Listen for CAPTCHA solving events
const client = await page.createCDPSession();
 
client.on('Captcha.detected', (result) => {
console.log('Captcha detected:', result);
});
 
await new Promise((resolve, reject) => {
client.on('Captcha.solveFinished', (result) => {
if (result.success) resolve();
});
client.on('Captcha.solveFailed', () =>
reject(new Error('Captcha solve failed'))
);
setTimeout(() =>
reject(new Error('Captcha solve timeout')),
5 * 60 * 1000
);
});

Advanced Configuration API

Scraping Browser provides a series of advanced APIs for fine-grained control over the CAPTCHA solver’s behavior. Here are the supported APIs:

API NameDescription
Captcha.setAutoSolveControl automatic CAPTCHA solving behavior
Captcha.setTokenSet authentication token for CAPTCHA service
Captcha.setConfigConfigure all CAPTCHA solver parameters
Captcha.solveManually trigger CAPTCHA solving process

Detailed API Description

1. Captcha.setAutoSolve

Configuration interface to control automatic CAPTCHA solving behavior.

const client = await page.createCDPSession();
await client.send('Captcha.setAutoSolve', {
    autoSolve: false,
    options: [{
        type: 'recaptcha',  // Options: recaptcha | turnstile
        disabled: false,
    }]
});

2. Captcha.setToken

Set authentication token for CAPTCHA solving service.

await client.send('Captcha.setToken', {
    apiKey: 'your-token'
});

3. Captcha.setConfig

Configure all parameters for the CAPTCHA solver.

await client.send('Captcha.setConfig', {
    apiKey: 'your-token',
    autoSolve: true,
    enabledForRecaptcha: true,    // Enable reCAPTCHA solving
    enabledForRecaptchaV3: true,  // Enable reCAPTCHA v3 solving
    enabledForTurnstile: true    // Enable Turnstile solving
});

4. Captcha.solve

Manually trigger CAPTCHA solving process.

const result = await client.send('Captcha.solve', {
    detectTimeout: 10 * 1000,
    options: JSON.stringify([{
        type: 'rcaptcha',
        disabled: true,  // Disable rCaptcha solving
    }])
});
console.log(result);  // { type: 'recaptcha', success: true, message: 'solve_finished', token: 'xxx' }