aw1875 / puppeteer-hcaptcha

A library to solve hcaptcha challenges that are automated within puppeteer. You can automatically set response values where they should be so the only thing left for you is submitting the page or you can get the response token.
https://www.npmjs.com/package/puppeteer-hcaptcha
137 stars 38 forks source link
hcaptcha hcaptcha-solver puppeteer solve-hcaptcha-challenges

hCaptcha solver for puppeteer

⚠️ Important ⚠️

I'm currently searching for a better TFJS model as it seems the coco-ssd model thats currently being used is struggling with hCaptchas images more frequently as they are now blurred a little. If you have any suggestions please create a new issue with the TFJS recommendation template so I can take a look. Thanks!


Most recent updates to the code can be found on the typescript branch.


A library to solve hcaptcha challenges that are automated within puppeteer. You can automatically set response values where they should be so the only thing left for you is submitting the page or you can get the response token. Average response time is rougly 13 - 20 seconds with TensorFlow's Image Recognition.

If you like this project feel free to donate!

Donate with PayPal

Install

npm i puppeteer-hcaptcha

Usage

await hcaptcha(page);
await hcaptchaToken(url);

Automatically set respone value (see demo)

// Require puppeteer extra and puppeteer stealth
const puppeteer = require("puppeteer-extra");
const pluginStealth = require("puppeteer-extra-plugin-stealth");

// Require our hcaptcha method
const { hcaptcha } = require("puppeteer-hcaptcha");

// Tell puppeteer to use puppeteer stealth
puppeteer.use(pluginStealth());

(async () => {
    // Instantiate a new browser object
    // Ignore errors associated to https
    // Can be headless but for example sake we want to show the browser
    // Set your desired arguments for your puppeteer browser
    const browser = await puppeteer.launch({
        ignoreHTTPSErrors: true,
        headless: false,
        args: [
            `--window-size=600,1000`,
            "--window-position=000,000",
            "--disable-dev-shm-usage",
            "--no-sandbox",
            '--user-data-dir="/tmp/chromium"',
            "--disable-web-security",
            "--disable-features=site-per-process",
        ],
    });

    // Get browser pages
    const [page] = await browser.pages();

    // Send page to your url
    await page.goto("URL OF PAGE WITH CAPTCHA ON IT");

    // Remove the page's default timeout function
    await page.setDefaultNavigationTimeout(0);

    // Call hcaptcha method passing in our page
    await hcaptcha(page);

    // Your page is ready to submit.
    // Captcha solving should be the last function on your page so we
    // don't have to worry about the response token expiring.
    /**
     * Example:
     * await page.click("loginDiv > loginBtn");
     */
})();

Return response token only (see demo)

// Require our hcaptchaToken method
const { hcaptchaToken } = require("puppeteer-hcaptcha");

(async () => {
    // Create Start Time
    const startTime = Date.now();

    // Call hcaptchaToken method passing in your url
    let token = await hcaptchaToken("URL OF PAGE WITH CAPTCHA ON IT");

    // Get End Time
    const endTime = Date.now();

    // Log timed result to console
    console.log(`Completed in ${(endTime - startTime) / 1000} seconds`);

    // P0_eyJ0eXAiOiJ...
    console.log(token);
})();

Credits

Changelog

4.1.6 (July 27, 2022)

4.1.5 (Febuary 15, 2021)

4.1.4 (December 27, 2021)

4.1.3 (December 22, 2021)

4.1.2 (December 16, 2021)

4.1.1 (December 14, 2021)

4.1.0 (December 14, 2021)

4.0.1 (December 8, 2021)

4.0.0 (December 8, 2021)

3.0.6 (December 7, 2021)

3.0.5 (December 7, 2021)

3.0.4 (April 30, 2021)

3.0.3 (April 29, 2021)

3.0.2 (April 23, 2021)

3.0.1 (April 22, 2021)

3.0.0 (April 4, 2021)

2.0.2 - 2.0.3 (April 2, 2021)

2.0.1 (March 28, 2021)

2.0.0 (March 23, 2021)

1.0.1 - 1.0.2 (March 16, 2021)

1.0.0 (March 16, 2021)

Known Issues

I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

Stems from TensorFlow. Not entirely sure how to fix this but it doesn't impact the solver.