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 2-12 seconds (if Google isn't rate limiting for too many requests, otherwise it can take much longer or possibly fail).
npm i puppeteer-hcaptcha
await hcaptcha(page, client);
page
- Puppeteer Page Typeclient
- Google Vision ImageAnnotatorClient Type
await hcaptchaToken(url, client)
url
-string
: url of page with captcha on itclient
- Google Vision ImageAnnotatorClient Type
Automatically set respone value (see demo)
// Require puppeteer extra, puppeteer stealth, google vision
const puppeteer = require('puppeteer-extra')
const pluginStealth = require('puppeteer-extra-plugin-stealth')
const vision = require("@google-cloud/vision");
// Require our hcaptcha method
const { hcaptcha } = require('puppeteer-hcaptcha');
// Instantiate a new Google Vision Client
// This is important so make sure keyFilename points to your credentials
// Our solver method will be using this to speed up the process
const client = new vision.ImageAnnotatorClient({
keyFilename: "YOUR GOOGLE CREDENTIALS",
});
// 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 and google vision client
await hcaptcha(page, client);
// 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.
})();
Return response token only (see demo)
// Require puppeteer extra, puppeteer stealth, google vision
const puppeteer = require('puppeteer-extra')
const pluginStealth = require('puppeteer-extra-plugin-stealth')
const vision = require("@google-cloud/vision");
// Require our hcaptchaToken method
const { hcaptchaToken } = require('puppeteer-hcaptcha');
// Instantiate a new Google Vision Client
// This is important so make sure keyFilename points to your credentials
// Our solver method will be using this to speed up the process
const client = new vision.ImageAnnotatorClient({
keyFilename: "YOUR GOOGLE CREDENTIALS",
});
// Tell puppeteer to use puppeteer stealth
puppeteer.use(pluginStealth());
(async () => {
// Call hcaptcha method passing in url and google vision client
let token = await hcaptchaToken('URL OF PAGE WITH CAPTCHA ON IT', client);
// W0_eyJ0eXAiOiJ...
console.log(token);
})();
- Thanks to Futei, JimmyLaurent, Nayde, DinoHorvat, and Tal
- Reverted changes made in v3.0.1
- Created temporary fix for HSJ requests while I look into a proper solution
- Pushed a fix for when the response token is received from the initial request
- Big changes to solving logic to follow changes that hCaptcha has made to their requests.
-
Made changes to requests based on changes hCaptcha made. Added list of User Agents so that they are randomized on request (seems to speed up response time generally)
-
Fixed issue finding useragents file
- Fixed issues with cloudflare sites not returning solved token (see #2).
- Added Google Vision for image recognition to speed up the process
- Added ability to solve captcha on a page or just return the response token
- Massive shoutout goes to Tal for all the help implementing Google Vision
- The idea to do this came from him. He has a super quick solver for GoLang if you are looking for that. He also added a REST API Version of his solver that can definitely be useful if you don't know anything about GoLang
- Small updates to README documentation
- Initial release
- Huge shoutout to these people for the release of this package
- Futei - Initial project
- JimmyLaurent - Initial Node Module
- Nayde - The idea of porting functionality to be usable through puppeteer
- DinoHorvat - Help with response token issue (workaround was found out before release)
UnhandledPromiseRejectionWarning: Error: 13 INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: read ECONNRESET
Stems from Google Vision API. Occurs when too many requests are sent to Google Vision within a small time period.