/recaptcha-solver

Solve reCAPTCHA challenges by using offline speech recognition.

Primary LanguageTypeScriptMIT LicenseMIT

reCAPTCHA Solver

Solve reCAPTCHA challenges by using offline speech recognition.

It can be very useful when you want to do E2E tests with your application protected by reCAPTCHA.

Requirements:

  • ffmpeg installed

Features:

  • Offline: A pretrained small model is included.
  • Fast: Solve each challenge in less than 3 seconds.
  • Accurate: Over 95% accuracy.
  • Auto-retry: If the challenge is not solved, it will retry it.
  • Supports reCAPTCHA v2 and v3 (invisible).

Install

npm i recaptcha-solver

It will automatically download a 40 MB acoustic model which will be used to solve the challenges.

The model is from https://alphacephei.com/vosk/models (Apache 2.0).

Example

Checkout example/index.mjs!

import { chromium } from "playwright-core";
import { solve } from "recaptcha-solver";

const EXAMPLE_PAGE = "https://www.google.com/recaptcha/api2/demo";

main();

async function main() {
    const browser = await chromium.launch({ headless: false });
    const page = await browser.newPage();
    await page.goto(EXAMPLE_PAGE);

    console.time("solve reCAPTCHA");
    await solve(page);
    console.log("solved!");
    console.timeEnd("solve reCAPTCHA");

    await page.click("#recaptcha-demo-submit");

    page.on("close", async () => {
        await browser.close();
        process.exit(0);
    });
}
❯ node example/index.mjs
solved!
solve reCAPTCHA: 4.285s

With VERBOSE environment variable:

❯ VERBOSE=1 node example/index.mjs
[reCAPTCHA solver] bframe loaded: false
[reCAPTCHA solver] invisible: false
[reCAPTCHA solver] action required: true
[reCAPTCHA solver] [Mutex] init locked
[reCAPTCHA solver] [Mutex] ready waiting
[reCAPTCHA solver] [Mutex] get sound unlocked
[reCAPTCHA solver] [Mutex] ready locked
[reCAPTCHA solver] reconized: for their start urine
[reCAPTCHA solver] [Mutex] done waiting
[reCAPTCHA solver] [Mutex] verified unlocked
[reCAPTCHA solver] [Mutex] done locked
[reCAPTCHA solver] passed: true
solved!
solve reCAPTCHA: 4.072s

Demo

demo.mp4 (23s)

demo.mp4