DEV Community

2captcha
2captcha

Posted on

How to Solve and Overcome reCAPTCHA Automatically with Puppeteer and Auto Captcha Integration

Automating reCAPTCHA Bypass Using Puppeteer

This comprehensive guide walks you through the process of bypassing reCAPTCHA challenges using Puppeteer and an auto captcha-solving technique.

You can read original article here - How to automatically solve and bypass reCAPTCHA using Puppeteer and Auto Captcha Filler

Discover how to programmatically solve Google reCAPTCHA using Puppeteer alongside an automated captcha resolution system in this step-by-step tutorial.

Automating reCAPTCHA Challenges Using Puppeteer and Captcha Solvers

Here, we demonstrate the process of bypassing image-based reCAPTCHA tasks (3x3 or 4x4 grids) by leveraging Puppeteer in combination with 2Captcha, a third-party captcha-solving service.

The script automates interaction with reCAPTCHA by retrieving the challenge, sending it for API-based resolution, and simulating user actions like clicking the correct answers provided by the solver.

This fully automated approach simplifies CAPTCHA bypassing in web automation scenarios.

Setting Up the Script

Clone the Repository

git clone git@github.com/2captcha/puppeteer-recaptcha-solver-using-clicks.git  
cd puppeteer-recaptcha-solver-using-clicks  
Enter fullscreen mode Exit fullscreen mode

Install Dependencies

npm install 
Enter fullscreen mode Exit fullscreen mode

Run the Script

npm run start 
Enter fullscreen mode Exit fullscreen mode

Configuration Instructions

To enable the script, configure your 2Captcha API key by setting the APIKEY environment variable:

export APIKEY=your_api_key
Enter fullscreen mode Exit fullscreen mode

How the Script Operates

  • CAPTCHA Extraction: The challenge image and parameters are programmatically retrieved.

  • Data Submission: The image data is sent to the solver API, which resolves the CAPTCHA by identifying grid cells containing target objects.

  • Interaction Simulation: Using the provided solution, Puppeteer clicks the required cells in the reCAPTCHA widget and submits the challenge.

Example of Extraction Output:

{  
  "rows": 3,  
  "columns": 3,  
  "type": "GridTask",  
  "comment": "Select all images with crosswalks. Click verify when none are left.",  
  "body": "XXXXXXXX"  
}  
Enter fullscreen mode Exit fullscreen mode

Example of Solver Output:

{  
  "status": 1,  
  "data": "click:3/6/8",  
  "id": "XXXXXXXX"  
}  
Enter fullscreen mode Exit fullscreen mode

Here, click:3/6/8 directs you to click the 3rd, 6th, and 8th grid squares. Grid numbering begins at the top-left corner, progressing row by row.

Key Features

  • Token-Free Approach: Avoids managing tokens manually, instead relying on grid interactions to validate responses.

  • Simplified Process: Leverages reCAPTCHA’s built-in verification to simplify logic and reduce complexity.

Advantages:

  • Reduces reliance on token management.

  • Mimics user behavior, enhancing compatibility with reCAPTCHA systems.

Challenges:

  • Requires browser automation, which adds code complexity.

  • CAPTCHA-solving cost and speed may vary with task difficulty.

Error Management

  • Unsolvable CAPTCHAs: If a CAPTCHA is deemed unsolvable, retry or escalate the task.

  • Rate Limits: Excessive requests may temporarily block your IP; mitigate this by switching IPs or waiting before retrying.

For Python users, check out our repository for similar automation examples using Selenium and Python: [reCAPTCHA Solver with 2Captcha and Selenium].

Top comments (0)