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

Undefined response #56

Closed izoomrud closed 2 years ago

izoomrud commented 2 years ago

Hello, I'm trying to run this script

// 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("https://www.bestchange.ru/index.php?nt=bonus");

  // 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);
})();

but I get this response image what could be the problem?

Ryxwaer commented 2 years ago

Hello, I was about to make a question when I found this one so I will put it here. It looks so we may have the same problem. I was trying to make this work for a few hours with no lusk so far. I have successfully installed npm i puppeteer-hcaptcha I modified demos just by pasting following url: https://democaptcha.com/demo-form-eng/hcaptcha.html Now this is my output when I try to run them:

node --trace-uncaught solve.js

/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'objectLocalization')
at getAnswers (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:80:18)
at tryToSolve (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:178:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async solveCaptcha (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:255:22)
at async Page._onBindingCalled (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:998:28)
at ExecutionContext._evaluateInternal (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ExecutionContext.evaluate (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
at async hcaptcha (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:281:17)
at async /home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/demos/solve.js:40:3
Thrown at:
at _evaluateInternal (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Node.js v17.9.0

node --trace-uncaught token.js

Completed in 0 seconds
undefined

I would be glad for any response. Thanks

aw1875 commented 2 years ago

Hello, I'm trying to run this script

// 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("https://www.bestchange.ru/index.php?nt=bonus");

  // 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);
})();

but I get this response image what could be the problem?

When I went to the website you're attempting to run the script on I wasn't presented with any sort of hCaptcha response. This could be the reason you are receiving undefined. It does seem like there is an hCaptcha script check when loading the site but there isn't any actual challenge to solve.

aw1875 commented 2 years ago

Hello, I was about to make a question when I found this one so I will put it here. It looks so we may have the same problem. I was trying to make this work for a few hours with no lusk so far. I have successfully installed npm i puppeteer-hcaptcha I modified demos just by pasting following url: https://democaptcha.com/demo-form-eng/hcaptcha.html Now this is my output when I try to run them:

node --trace-uncaught solve.js

/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'objectLocalization')
at getAnswers (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:80:18)
at tryToSolve (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:178:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async solveCaptcha (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:255:22)
at async Page._onBindingCalled (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:998:28)
at ExecutionContext._evaluateInternal (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ExecutionContext.evaluate (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
at async hcaptcha (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:281:17)
at async /home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/demos/solve.js:40:3
Thrown at:
at _evaluateInternal (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Node.js v17.9.0

node --trace-uncaught token.js

Completed in 0 seconds
undefined

I would be glad for any response. Thanks

The error looks like it's looking for the objectLocalization method which doesn't exist on any recent versions of the code. That method only lives within the Google Cloud Vision SDK which has long been removed (only exists within a separate branch of the repository that was requested for continuing with the use of it). Please make sure you're using the most up-to-date version of the package which should be 4.1.5. Please let me know if anything changes once updating the package.

Ryxwaer commented 2 years ago

Thank you for the reply. I am using most recent version 4.1.5. Even method for getting just the token isn't working for me. I tryed to reinstall it a few times but nothing changed most of the time. But when I didn't call npm audit fix after the instllation then It was already taking some time before failing. I still got undefined after trying to get captcha token by using demo and the same URL as in my previous comment. But this time doing something for 42 seconds (hopefully trying to selve the captcha). The second demo solve.js is running but I can't tell if it is doing something or if it will end any time soon. Also do I need to fix these warnings from tensorflow? image I am looking forward to your reply. Thanks.

aw1875 commented 2 years ago

As stated in the documentation the tensorflow messages are nothing to worry about and shouldn't have an impact on how the project functions. Like I said, it did seem like I wasn't presented with an hCaptcha form when I visited the website you presented which could be why the functions are returning undefined. Are you still attempting to solve the captcha on the url "https://www.bestchange.ru/index.php?nt=bonus"? If you are I suggest giving https://2captcha.com/demo/hcaptcha a try to see if it presents the same issues so we can narrow down what is happening.

tipsey commented 2 years ago

Hello, I was about to make a question when I found this one so I will put it here. It looks so we may have the same problem. I was trying to make this work for a few hours with no lusk so far. I have successfully installed npm i puppeteer-hcaptcha I modified demos just by pasting following url: https://democaptcha.com/demo-form-eng/hcaptcha.html Now this is my output when I try to run them:

I have the same issue. Although about 25% of the time it does solve the hCaptcha. I updated to Node.js v 18.1.0. Anyone with a solution?

greebzon commented 2 years ago

Hello, I was about to make a question when I found this one so I will put it here. It looks so we may have the same problem. I was trying to make this work for a few hours with no lusk so far. I have successfully installed npm i puppeteer-hcaptcha I modified demos just by pasting following url: https://democaptcha.com/demo-form-eng/hcaptcha.html Now this is my output when I try to run them:

node --trace-uncaught solve.js

/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'objectLocalization')
at getAnswers (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:80:18)
at tryToSolve (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:178:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async solveCaptcha (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:255:22)
at async Page._onBindingCalled (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:998:28)
at ExecutionContext._evaluateInternal (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ExecutionContext.evaluate (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
at async hcaptcha (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer-hcaptcha/hcaptcha.js:281:17)
at async /home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/demos/solve.js:40:3
Thrown at:
at _evaluateInternal (/home/ryxwaer/Documents/Automated_Jobs/CAPTCHA/pupeteer/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Node.js v17.9.0

node --trace-uncaught token.js

Completed in 0 seconds
undefined

I would be glad for any response. Thanks

Hi. Same issue.

const puppeteer = require("puppeteer-extra");
const pluginStealth = require("puppeteer-extra-plugin-stealth");
require('browser-env')();

const { hcaptcha } = require("puppeteer-hcaptcha");
puppeteer.use(pluginStealth())

async function start(){
    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",
        ],
      });
await page.goto('https://2captcha.com/demo/hcaptcha');
await page.setDefaultNavigationTimeout(0);
await hcaptcha(page);
}
Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'objectLocalization')
    at getAnswers (D:\Projects\automatic\node_modules\puppeteer-hcaptcha\hcaptcha.js:80:18)
    at tryToSolve (D:\Projects\automatic\node_modules\puppeteer-hcaptcha\hcaptcha.js:178:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async solveCaptcha (D:\Projects\automatic\node_modules\puppeteer-hcaptcha\hcaptcha.js:255:22)
    at async Page._onBindingCalled (D:\Projects\automatic\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:998:28)
    at ExecutionContext._evaluateInternal (D:\Projects\automatic\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ExecutionContext.evaluate (D:\Projects\automatic\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async hcaptcha (D:\Projects\automatic\node_modules\puppeteer-hcaptcha\hcaptcha.js:281:17)
aw1875 commented 2 years ago

@greebzon the objectLocalization is only related to Google Cloud Vision which is no longer included in any of the newer versions of the package. I will be closing this issue now as it seems like all the posts are related to an outdated version of the code which is not supported.