Puppeteer is a powerful tool for automating web applications for testing and parsing. However, it can be challenging to bypass captcha checks in Puppeteer. A special recognition automation service is required to solve captchas automatically. 2Captcha is a captcha-solving service that can be integrated with Puppeteer to bypass captchas on any site.
Here is a step-by-step guide on how to use the 2Captcha solver extension in Puppeteer for bypassing captchas:
1. Download the 2Captcha solver extension and unzip it to the folder `./2captcha-solver` in the root of the project.
2. Install the following libraries: `puppeteer`, `puppeteer-extra`, `puppeteer-extra-plugin-stealth`, and `2captcha-solver`.
4. Write Puppeteer code to visit the target page and solve the captcha using 2Captcha.
Here is an example of how to use Puppeteer and 2Captcha to solve reCAPTCHA V2:
Congratulations, the captcha has been successfully passed! The full source code of the example is available on GitHub.
- The extension has many settings, for example, automatic solution of the specified type of captcha or support for proxy, all these settings are available in the file `./common/config.js`, in the folder with the unpacked extension.
- To automatically send reCAPTCHA V2, in the file `./common/config.js` change the value of the `autoSolveRecaptchaV2` field to `true`.
- You can use sandbox mode for testing. In sandbox mode, sent captchas will be sent to you. Learn more about sandbox you can read here.
- Puppeteer running in headless mode does not support loading extension, to solve this problem you can use xvfb.
In conclusion, Puppeteer and 2Captcha can be used together to bypass captchas on any site. The process is straightforward, and the pricing is reasonable. The service is regularly used by thousands of users, and there are several tutorials available online that demonstrate how to use Puppeteer and 2Captcha to solve captchas.