Working with CAPTCHA
For working and solving CAPTCHA in A-Parser, special methods are implemented that allow sending CAPTCHA for solving to a CAPTCHA solving service using scrapers:
- Util::AntiGate - solves CAPTCHAs in the form of images with inscriptions of letters/numbers/words
- Util::ReCaptcha2 - solves Google ReCaptcha v2
- Util::ReCaptcha3 - solves Google ReCaptcha v3
- Util::hCaptcha - solves hCaptcha CAPTCHAs
- Util::Turnstile - solves Cloudflare Turnstile CAPTCHAs
It is also easy to solve CAPTCHA using the method await this.parser.request()
For example, calling this method for Google ReCaptcha v2 would look like this:
await this.parser.request('Util::ReCaptcha2', this.conf.Util_ReCaptcha2_preset, {}, siteKey + ' ' + endPoint);
You can learn more in the example from the catalog Checking website categories through the cyren.com service
Learn more about Bypassing CAPTCHA
await this.captcha.*
Working with CAPTCHA
.recognize(preset, image, type[, overrides])
await this.captcha.recognize(preset, image, type, overrides)
- uploading a CAPTCHA for recognition
image
- binary image data for recognitionpreset
- indicates a preset for Util::AntiGatetype
is specified as one of: 'jpeg', 'gif', 'png'
The result will be a hash with fields:
answer
- text from the imageid
- CAPTCHA id, for the possibility to report an error later through.reportBad
error
- text error, if answer is not set
.recognizeFromUrl(preset, url[, overrides])
await this.captcha.recognizeFromUrl(preset, url, overrides)
- similar to the previous method, but the CAPTCHA will be automatically downloaded by the link (url), without using a proxy
.reportBad(preset, id[, overrides])
await this.captcha.reportBad(preset, id, overrides)
- inform the service that the CAPTCHA was solved incorrectly
Useful links
🔗 ⏩ Creating JS scrapers. Working with CAPTCHA
Video on how to write a JS scraper that supports AntiGate for solving CAPTCHAs on pages
🔗 Creating JS scrapers. Working with CAPTCHA
Article on how to write a JS scraper that supports AntiGate for solving CAPTCHAs on pages
🔗 Checking website categories through the cyren.com service
Example with the implementation of connecting Util::ReCaptcha2 in a JS scraper