Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha
Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha
Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha
Gathering detailed insights and metrics for puppeteer-extra-plugin-recaptcha
💯 Teach puppeteer new tricks through plugins.
npm install puppeteer-extra-plugin-recaptcha
Typescript
Module System
Min. Node Version
Node Version
NPM Version
95.1
Supply Chain
97.7
Quality
74.1
Maintenance
100
Vulnerability
100
License
JavaScript (59.86%)
TypeScript (39.86%)
HTML (0.19%)
Shell (0.09%)
Total Downloads
5,792,972
Last Day
1,468
Last Week
27,681
Last Month
119,818
Last Year
1,517,616
MIT License
7,028 Stars
604 Commits
766 Forks
114 Watchers
5 Branches
49 Contributors
Updated on Sep 02, 2025
Latest Version
3.6.8
Package Id
puppeteer-extra-plugin-recaptcha@3.6.8
Unpacked Size
411.33 kB
Size
83.22 kB
File Count
37
NPM Version
lerna/3.22.1/node@v18.12.1+arm64 (darwin)
Node Version
18.12.1
Published on
Mar 01, 2023
Cumulative downloads
Total Downloads
Last Day
4.5%
1,468
Compared to previous day
Last Week
-2.6%
27,681
Compared to previous week
Last Month
-12.9%
119,818
Compared to previous month
Last Year
-1.6%
1,517,616
Compared to previous year
3
2
A puppeteer-extra and playwright-extra plugin to solve reCAPTCHAs and hCaptchas automatically.
1yarn add puppeteer-extra-plugin-recaptcha 2# - or - 3npm install puppeteer-extra-plugin-recaptcha
If this is your first puppeteer-extra plugin here's everything you need:
1yarn add puppeteer puppeteer-extra puppeteer-extra-plugin-recaptcha 2# - or - 3npm install puppeteer puppeteer-extra puppeteer-extra-plugin-recaptcha
🎁 Note: Until we've automated changelog updates in markdown files please follow the
#announcements
channel in our discord server for the latest updates and changelog info.
Older changelog:
3.1.9
3.1.6
3.1.5
1for (const frame of page.mainFrame().childFrames()) { 2 await frame.solveRecaptchas() 3}
3.1.4
Page
and Frame
object (e.g. page.solveRecaptchas()
).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 2captcha token (= their apiKey) 6// 2captcha is the builtin solution provider but others would work as well. 7// Please note: You need to add funds to your 2captcha account for this to work 8const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha') 9puppeteer.use( 10 RecaptchaPlugin({ 11 provider: { 12 id: '2captcha', 13 token: 'XXXXXXX' // REPLACE THIS WITH YOUR OWN 2CAPTCHA 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})
1// `puppeteer-extra` and the recaptcha plugin are written in TS, 2// hence you get perfect type support out of the box :) 3 4import puppeteer from 'puppeteer-extra' 5import RecaptchaPlugin from 'puppeteer-extra-plugin-recaptcha' 6 7puppeteer.use( 8 RecaptchaPlugin({ 9 provider: { 10 id: '2captcha', 11 token: 'ENTER_YOUR_2CAPTCHA_API_KEY_HERE' 12 } 13 }) 14) 15 16// Puppeteer usage as normal (headless is "false" just for this demo) 17puppeteer.launch({ headless: false }).then(async browser => { 18 const page = await browser.newPage() 19 await page.goto('https://www.google.com/recaptcha/api2/demo') 20 21 // Even this `Puppeteer.Page` extension is recognized and fully type safe 🎉 22 await page.solveRecaptchas() 23 24 await Promise.all([ 25 page.waitForNavigation(), 26 page.click(`#recaptcha-demo-submit`) 27 ]) 28 await page.screenshot({ path: 'response.png', fullPage: true }) 29 await browser.close() 30})
If you'd like to see debug output just run your script like so:
1DEBUG=puppeteer-extra,puppeteer-extra-plugin:* node myscript.js
Tip: The recaptcha plugin works really well together with the stealth plugin.
These days captchas are unfortunately everywhere, with reCAPTCHA having the biggest "market share" in that space (> 80%). The situation got really bad, with privacy minded users (tracking blocker, VPNs) being penalized heavily and having to solve a lot of reCAPTCHA challenges constantly while browsing the web.
The stated reasons for this omnipresent captcha plague vary from site owners having to protect themselves against increasingly malicious actors to some believing that we're essentially forced into free labour to train Google's various machine learning endeavours.
In any case I strongly feel that captchas in their current form have failed. They're a much bigger obstacle and annoyance to humans than to robots, which renders them useless. My anarchist contribution to this discussion is to demonstrate this absurdity, with a plugin for robots with which a single line of code is all it takes to bypass reCAPTCHAs on any site.
Note: Since
v3.3.0
the plugin will solve hCaptchas as well, as they've gained significant marketshare through their Cloudflare partnership.
I thought about having the plugin solve captchas directly (e.g. using the audio challenge and speech-to-text APIs), but external solution providers are so cheap and reliable that there is really no benefit in doing that. ¯\_(ツ)_/¯
Please note: You need a provider configured for this plugin to do it's magic. If you decide to use the built-in 2captcha provider you need to add funds to your 2captcha account.
Currently the only builtin solution provider as it's the cheapest and most reliable, from my experience. If you'd like to throw some free captcha credit my way feel free to signup here (referral link, allows me to write automated tests against their API).
You can easily use your own provider as well, by providing the plugin a function instead of 2captcha credentials (explained in the API docs). PRs for new providers are welcome as well.
page.solveRecaptchas()
the plugin will attempt to find any active reCAPTCHAs & hCaptchas, extract their configuration, pass that on to the specified solutions provider, take the solutions and put them back into the page (triggering any callback that might be required).reCAPTCHAs use a per-site sitekey
. Interestingly enough the response token after solving a challenge is (currently) not tied to a specific session or IP and can be passed on to others (until they expire). This is how the external solutions provider work: They're being given a sitekey
and URL, solve the challenge and respond with a response token.
This plugin automates all these steps in a generic and robust way (detecting captchas, extracting their config and sitekey
) as well as triggering the (optional) response callback the site owner might have specified.
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.1DEBUG=puppeteer-extra,puppeteer-extra-plugin:* node myscript.js
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.
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}
1const { 2 captchas, 3 filtered, 4 solutions, 5 solved, 6 error 7} = await page.solveRecaptchas()
captchas
is an array of captchas found in the pagefiltered
is an array of captchas that have been detected but are ignored due to plugin optionssolutions
is an array of solutions returned from the providersolved
is an array of "solved" (= solution entered) captchas on the pagepage.solveRecaptchas()
is a convenience method that wraps the following steps:
1let { captchas, filtered, error } = await page.findRecaptchas() 2let { solutions, error } = await page.getRecaptchaSolutions(captchas) 3let { solved, error } = await page.enterRecaptchaSolutions(solutions)
If you wish for 2captcha to use a specific proxy (= IP address) while solving the captcha you can set the enviroment variables 2CAPTCHA_PROXY_TYPE
and 2CAPTCHA_PROXY_ADDRESS
.
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()
Copyright © 2018 - 2023, berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘. Released under the MIT License.
No vulnerabilities found.
@fisch0920/puppeteer-extra-plugin-recaptcha
A puppeteer-extra plugin to solve reCAPTCHAs and hCaptchas automatically.
puppeteer-extra-plugin-capsolver
manage to solve captcha challenges with puppeteer
@fagenorn/puppeteer-extra-plugin-recaptcha
A puppeteer-extra plugin to solve reCAPTCHAs and hCaptchas automatically.
puppeteer-extra-plugin-recaptcha-capmonster
A puppeteer-extra plugin that implements CapMonster support for puppeteer-extra-plugin-recaptcha.