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

[Bug]: Captcha Solving doesent work #40

Closed nabil-ak closed 2 years ago

nabil-ak commented 2 years ago

Describe the bug I wrote a script that do the same like yours and tries to solve the 2captcha demo captcha. But it dosent work i just get an error withhCaptcha solved incorrectly, please try again. the h-captcha-response value is also undefined. The script timeouts after 100-120 seconds without an result..... To Reproduce Steps to reproduce the behavior:

  1. Code block(s) with your code.
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("https://2captcha.com/demo/hcaptcha?difficulty=easy");

    // Remove the page's default timeout function
    await page.setDefaultNavigationTimeout(0);
    const startTime = Date.now();

    // 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");
     */
    console.log("Fertig");
    const [btn] = await page.$x('//*[@id="root"]/div/main/div/section/form/button[1]');
    const [token] = await page.$x('//*[@name="h-captcha-response"]');
    console.log(await page.evaluate(token => token.value, token))
    await btn.click();
    const endTime = Date.now();
    console.log(`Completed in ${(endTime - startTime) / 1000} seconds`);

})();

Screenshots image image

Errors Received hCaptcha solved incorrectly, please try again.

aw1875 commented 2 years ago

Seems like theres some issues with TensorFlow. Just broke down all the code and it looks like its not correctly identifying the images which is why we're having issues. I'm going to look into some alternatives and see if I can get it working when I have some free time this week.

nabil-ak commented 2 years ago

I found the Problem, i accidentally installed this fork of this project instead of the original one. 😅 He updated the packages in that fork and that caused the bug.