Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha-anti-captcha
Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha-anti-captcha
Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha-anti-captcha
Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha-anti-captcha
puppeteer-extra-plugin-recaptcha
A puppeteer-extra plugin to solve reCAPTCHAs and hCaptchas automatically.
puppeteer-extra-plugin-stealth
Stealth mode: Applies various techniques to make detection of headless puppeteer harder.
puppeteer-extra-plugin-user-data-dir
Custom user data directory for puppeteer.
puppeteer-extra-plugin
Base class for puppeteer-extra plugins.
npm install puppeteer-extra-plugin-recaptcha-anti-captcha
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
8 Commits
1 Watching
1 Branches
1 Contributors
Updated on 24 Nov 2024
Cumulative downloads
Total Downloads
Last day
200%
3
Compared to previous day
Last week
2,433.3%
76
Compared to previous week
Last month
275%
90
Compared to previous month
Last year
0%
499
Compared to previous year
2
This is a plugin for puppeteer-extra-plugin-recaptcha that implements Anti-Captcha provider to the solver.
You can still use the 2CAPTCHA provider
1npm install puppeteer-extra-plugin-recaptcha-anti-captcha
If this is your first puppeteer-extra plugin here's everything you need:
1npm install puppeteer puppeteer-extra puppeteer-extra-plugin-recaptcha-anti-captcha
The plugin essentially provides a mighty page.solveRecaptchas()
method that does everything needed automagically.
1// puppeteer-extra is a drop-in replacement for puppeteer, 2// it augments the installed puppeteer with plugin functionality 3const puppeteer = require('puppeteer-extra') 4 5// add recaptcha plugin and provide it your anti-captcha token (= their apiKey) 6// anti-captcha is the builtin solution provider but others would work as well. 7// Please note: You need to add funds to your anti-captcha account for this to work 8const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha-anti-captcha') 9puppeteer.use( 10 RecaptchaPlugin({ 11 provider: { 12 id: 'antigate', // or '2captcha' 13 token: 'XXXXXXX' // REPLACE THIS WITH YOUR OWN 2CAPTCHA API KEY OR ANTI-CAPTCHA API KEY ⚡ 14 }, 15 visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved) 16 }) 17) 18 19// puppeteer usage as normal 20puppeteer.launch({ headless: true }).then(async browser => { 21 const page = await browser.newPage() 22 await page.goto('https://www.google.com/recaptcha/api2/demo') 23 24 // That's it, a single line of code to solve reCAPTCHAs 🎉 25 await page.solveRecaptchas() 26 27 await Promise.all([ 28 page.waitForNavigation(), 29 page.click(`#recaptcha-demo-submit`) 30 ]) 31 await page.screenshot({ path: 'response.png', fullPage: true }) 32 await browser.close() 33})
1interface PluginOptions { 2 /** Visualize reCAPTCHAs based on their state */ 3 visualFeedback: boolean // default: true 4 /** Throw on errors instead of returning them in the error property */ 5 throwOnError: boolean // default: false 6 /** Only solve captchas and challenges visible in the browser viewport */ 7 solveInViewportOnly: boolean // default: false 8 /** Solve scored based captchas with no challenge (e.g. reCAPTCHA v3) */ 9 solveScoreBased: boolean // default: false 10 /** Solve invisible captchas that have no active challenge */ 11 solveInactiveChallenges: boolean // default: false 12}
page.solveRecaptchas()
is called.page.solveRecaptchas()
?page.solveRecaptchas()
on a page that has no reCAPTCHAs nothing bad will happen (😄) but the promise will resolve and the rest of your code executes as normal.By default the plugin will never throw, but return any errors silently in the { error }
property of the result object. You can change that behaviour by passing throwOnError: true
to the initializier and use try/catch
blocks to catch errors.
For convenience and because it looks cool the plugin will "colorize" reCAPTCHAs depending on their state (violet = detected and being solved, green = solved). You can turn that feature off by passing visualFeedback: false
to the plugin initializer.
By default the plugin will only solve reCAPTCHAs showing up on the immediate page. In case you encounter captchas in frames the plugin extends the Puppeteer.Frame
object with custom methods as well:
1// Loop over all potential frames on that page 2for (const frame of page.mainFrame().childFrames()) { 3 // Attempt to solve any potential captchas in those frames 4 await frame.solveRecaptchas() 5}
In addition you might want to disable site isolation, so puppeteer is able to access cross-origin iframes:
1puppeteer.launch({ 2 args: [ 3 '--disable-features=IsolateOrigins,site-per-process,SitePerProcess', 4 '--flag-switches-begin --disable-site-isolation-trials --flag-switches-end' 5 ] 6})
In case you're not using browser.newPage()
but re-use the existing about:blank
tab (which is not recommended for various reasons) you will experience a page.solveRecaptchas is not a function
error, as the plugin hasn't hooked into this page yet. As a workaround you can manually add existing pages to the lifecycle methods of the plugin:
1const recaptcha = RecaptchaPlugin() 2const pages = await browser.pages() 3for (const page in pages) { 4 // Add plugin methods to existing pages 5 await recaptcha.onPageCreated(page) 6}
page.solveRecaptchas
:1await page.waitForSelector('iframe[src*="recaptcha/"]') 2await page.solveRecaptchas()
No vulnerabilities found.
No security vulnerabilities found.