Puppeteer captcha solver

Bypass reCAPTCHA, Cloudflare Turnstile and any captchas in Puppeteer with fastest solving service 2Captcha.

No risk. Pay only for solved captchas

Quick Start
Puppeteer captcha solver in action

Short guide: How to start using extension in Puppeteer for interact with 2Captcha anti captcha API

  • Sign up on the captcha solving service
  • Installing Puppeteer and other required packages:
  • Download archive with the extension
  • Unzip it to the folder ./2captcha-solver in the project root
  • Setting up the extension
  • Launching and initializing the extension in Puppeteer
How to Bypass CAPTCHAs With Puppeteer Automatically, Puppeteer reCAPTCHA Solver & CAPTCHA bypass
Bypass reCAPTCHA with Puppeteer

Puppeteer captcha bypass: How it works

The 2Captcha service is designed to automatically recognize captchas and bypass them.

The bypass process is as follows: using the API, the customer passes a set of necessary parameters from the captcha placement page to the service, where the employee solves it. After that, the customer requests a set of parameters that must be passed to the appropriate fields to solve the captcha on the page.

The captcha recognition service is fully automated.

The API of the service can be used to work with Puppeteer, Selenium, Playwright.

Avoid captcha in Puppeteer using "puppeteer-extra-plugin-stealth"

Puppeteer logo

Puppeteer is a Node library that allows you to launch a browser and perform various actions in it. Puppeteer Node.js library is a great tool for a variety of tasks that require browser automation. The advantages of Puppeteer are its simplicity and the ability to work in headless mode. There are plugins for Puppeteer that allow you to hide the fact of automation. Hiding the fact of automation is important when developing parsers, as this will allow the browser to look more like a person and not be exposed.

Using Puppeteer with 2Captcha service

To bypass captchas in Puppeteer a special solving service is required.

The following tools are used to bypass captcha: "puppeteer", "puppeteer-extra" and "puppeteer-extra-plugin-stealth".

puppeteer-extra is a lightweight wrapper around Puppeteer

puppeteer-extra-plugin-stealth is an addition to puppeteer-extra designed to hide traces of automation.

Bypass captcha with Puppeteer node library

There is a manual to learn how to use the 2Captcha solver extension together with the Puppeteer library to perform web scraping, testing, and creating website bots.

Read the bypass instructions for details.

Manual: How to solve reCAPTCHA in Puppeteer using extension

1. Installing components

Installing Puppeteer and other required packages:

npm i puppeteer puppeteer-extra puppeteer-extra-plugin-stealth

2. Setting up the extension

Download archive with the extension, and unzip it to the folder ./2captcha-solver in the root of the project.

The extension has many settings, including automatic solution of the specified type of captcha, support for proxy, and other settings. The settings are available in the file ./common/config.js. To add settings for the automatic reCAPTCHA V2 solution, you need to open the file ./common/config.js and change the value of the autoSolveRecaptchaV2 field to true.

Next, you need to configure the extension:

  1. Enter your API key in the extension settings file ./common/config.js. Your key must be written to the value of the apiKey field. You can see and copy you're API key on the page. Example: apiKey: "8080629c1221fdd82m8080000ff0c99c"

  2. Disable opening the extension settings page after installation. To do this, in the file ./manifest.json delete the following lines:

"options_ui": {
    "page": "options/options.html",
    "open_in_tab": true
},

3. Browser Automation

Launching and initializing the extension in Puppeteer:

const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const { executablePath } = require('puppeteer'); 

(async () => {
  const pathToExtension = require('path').join(__dirname, '2captcha-solver');
  puppeteer.use(StealthPlugin())
  const browser = await puppeteer.launch({
    headless: false,
    args: [
      `--disable-extensions-except=${pathToExtension}`,
      `--load-extension=${pathToExtension}`,
    ],
    executablePath: executablePath()
  });

  const [page] = await browser.pages()
})();

3.1 Opening a page

Opening a page reCAPTCHA demo, and sending a captcha.

Using page.goto() we go to the page reCAPTCHA demo. Next, you need to send a captcha for a solution, this can be done manually or automatically.

In our example, we will send a captcha manually, for this we wait until the extension button with the CSS selector .captcha-solver is available, then click on this button. After clicking on the button, the captcha will go to the service for a solution.

// Opening a page
await page.goto('https://2captcha.com/demo/recaptcha-v2') 

// Waiting for the element with the CSS selector ".captcha-solver" to be available
await page.waitForSelector('.captcha-solver')
// Click on the element with the specified selector
await page.click('.captcha-solver')

3.2 Checking the captcha status

After receiving a response from the service, the extension button .captcha-solver will change the value of the data attribute data-state. By observing the value of this data-state attribute, you can monitor the state of the extension. After solving the captcha, the value of this attribute will change to "solved".

Description of the values of the data-state attribute:

AttributeDescription
data-state="ready"The extension is ready to solve the captcha. To send a captcha, you need to click on the button.
data-state="solving"Solving the captcha.
data-state="solved"Captcha has been successfully solved
data-state="error"An error when receiving a response or a captcha was not successfully solved.

At this step, you need to wait until the captcha is solved, after that the attribute value will change to "solved", this will signal the successful solution of the captcha. After this step, you can do the necessary actions.

// By default, waitForSelector waits for 30 seconds, but this time is usually not enough, so we specify the timeout value manually with the second parameter. The timeout value is specified in "ms".
await page.waitForSelector(`.captcha-solver[data-state="solved"]`, {timeout: 180000})

4. Performing actions

After solving the captcha, we can start doing the necessary actions on the page. In our example, we will click on the "Check" button to check the correctness of the received captcha solution. After successfully passing the check, you will see the message "Captcha is passed successfully!".

// Click on the "Check" button to check the successful solution of the captcha.
await page.click("button[type='submit']")

Congratulations, the captcha has been successfully passed! The full source code of the example.

Cloudflare Turnstile logo

Cloudflare captcha bypass

Automated bots are blocked by Cloudflare captcha service. The 2Captcha service can be used to bypass Cloudflare captcha in Puppeteer on any page.

The API of the service can be used in Puppeteer. To bypass Cloudflare in Puppeteer, you need to integrate a library to interact with the API. Read the API instructions for details.

Cloudflare captcha bypass service

Best Puppeteer anti captcha service

A Node.js framework called Puppeteer offers a high-level API for controlling headless versions of Chrome or Chromium via the DevTools Protocol. This API employs headless Chromium instances that are under remote control as a gateway to access a browser's (chrome's) capacity to render a webpage and its JavaScript components. Puppeteer defaults to running headless, but may set it up to run in non-headless mode as well (full Chrome or Chromium). The tool is often used by testers and parsers. You can use the 2Captcha solver extension with Puppeteer to solve captcha.

According to CaptchaTheCat analytics, 2Captcha is the best service.

captchathecat
Using 2Captcha solver extension with Puppeteer to bypass captcha

Need a customized solution? Try captcha solver API

Bypass captcha using our SDK

If browser automation with Puppeteer looks too complex and resource wasting for your case there's always an alternative approach: you can build request-based solution and use our SDK libraries programming languages: Java, C#, C++, PHP, Python, and Ruby. The documentation has been collected on the official GitHub page.

Products

Logo of «2Captcha»To home page

Copying any part of this website without the explicit permission of the website owner is illegal.

  • «GDPR» logo
  • «SSL secured» logo
  • «Google privacy policy» logo
  • «S/MIME» logo
  • «CCPA» logo
#1
In the monitoring service rating«CaptchaTheCat» logo
Connect with us
  • «2Captcha» on GitHub
  • «2Captcha» on LinkedIn
  • «2Captcha» on x
  • «2Captcha» YouTube channel