Pull to refresh

Puppeteer CAPTCHA bypass by Token or Clicks: Which is Faster? A Practical Comparison

Reading time4 min
Views1.1K
Original author: Александр

In my work, I often encounter various services designed to simplify tasks across different areas. I’m not talking about tools like GSA or A-Parser but about Zennoposter or BAS. I am no professor in automation, so I’ll explain in layman's terms: these services are essentially complex, multi-layered platforms that allow the creation of bots and scripts to perform almost any task without human intervention—a sort of “basic neural network.” By the way, such services existed long before neural networks became mainstream for everyday use.

While exploring BAS, I encountered a situation where many developers creating BAS scripts (ironically, developers developing) idealize CAPTCHA solving using clicks.

Puppeteer Bypass CAPTCHA - What Are We Talking About?

Here, I mean image-based and visual CAPTCHAs—those requiring you to select images on the screen or click on icons in a specific order. Examples include reCAPTCHA V2, hCaptcha, GeeTest CAPTCHA, and Rotate CAPTCHA.

Two Methods for Bypass CAPTCHA using Puppeteer: Tokens vs. Clicks

These CAPTCHAs can be solved in two ways: via the token method or the click method.

If you want to dive deeper into methods of CAPTCHA solving, here’s an excellent article: Understanding CAPTCHA Recognition: Breaking Down a Complex Process in the Simplest Terms!

Returning to the developers idealizing the click method, it should be noted that while this method can indeed be easier to implement and face fewer restrictions from CAPTCHA solving services, my experience has shown that bypass CAPTCHA with tokens is faster and more efficient than using clicks.

Before we Solve CAPTCHA with Puppeteer - Let's Get to the Facts:

Scenario: A demo reCAPTCHA V2 page.
Objective: Compare the speed of CAPTCHA recognition (in this case, reCAPTCHA V2) using the two methods.

To do this, I used two GitHub extensions. Although I aimed for out-of-the-box solutions, I had to tweak them slightly for my needs:

  1. For token-based CAPTCHA recognition: 2captcha-solver-in-puppeteer.

  2. For click-based CAPTCHA recognition: puppeteer-recaptcha-solver-using-clicks.

In truth, the comparison could’ve ended with the first extension since it supports both token and click methods. However, I began testing with the second and got mixed results, so I decided to include both for a clearer demonstration of click-based recognition speed.

Preparing Auto CAPTCHA Solvers

Here’s a detailed outline of the preparation steps for each solver, so we don’t revisit this later.

1. Preparing auto CAPTCHA solver for Token-Based Recognition
Both CAPTCHA solvers default to bypassCAPTCHA from a demo page of the service provider. To be objective, I decided to test on Google’s demo page instead. Google’s CAPTCHA is often more complex and reduces potential bias.

Changes Made to the First Extension:

  • config.js (path: \2captcha-solver\common)

    • In line 11, ensure the token method is set for CAPTCHA type.

    • Replace the API key in line 4 with your own.

  • manifest.js (one directory above config.js)

    • Remove this code snippet:

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

index File

  • Change the URL to point to Google’s CAPTCHA demo page.

  • Update the line:

await page.click("button[type='submit']")

to:

await page.click('#recaptcha-demo-submit')

This modification ensures the solver identifies the correct “submit” button since the class names differ between the Google and 2captcha demo pages.

2. Preparing CAPTCHA Solver Extension for Click-Based Recognition in the First Solver
Switching to the click method requires:

  • Modifying config.js to set “click” as the recognition method (API key remains unchanged).

Additionally, I commented out part of the index.js code to bypass issues where the solver couldn’t find the button. In my case, it was easier to manually click the “submit” button, but for automated recognition, further customization would be necessary. The commented-out code (lines 25-37) looked like this:

// Wait for the element with CSS selector ".captcha-solver"
await page.waitForSelector('.captcha-solver')
// Click the element with the specified selector
await page.click('.captcha-solver')

// Specify a custom timeout (in ms) since the default 30 seconds is often insufficient.
await page.waitForSelector(`.captcha-solver[data-state="solved"]`, {timeout: 150000})

// After solving the CAPTCHA, click the "check" button.
await page.click('#recaptcha-demo-submit')

// await browser.close();

After commenting, my code appeared as follows:

// // Wait for the element with CSS selector ".captcha-solver"
// await page.waitForSelector('.captcha-solver')
// // Click the element with the specified selector
// await page.click('.captcha-solver')

// // Specify a custom timeout (in ms).
// await page.waitForSelector(`.captcha-solver[data-state="solved"]`, {timeout: 150000})

// // Click the "check" button after solving the CAPTCHA.
// await page.click('#recaptcha-demo-submit')

// // await browser.close();

3. Preparing the Automatic CAPTCHA Solver Second Extension for Click-Based Recognition

This required more effort, though not extensive. All executable files are in the root directory, so there’s no need to navigate through folders. I added my API key, updated the target URL, and adjusted selectors. Google’s selectors differ from those on the 2captcha demo page, so the extension initially failed to work. I won’t detail every change since this extension is only for reference, but there’s an article on the original source if you want to explore: Automating reCAPTCHA Solving with Puppeteer: A Step-by-Step Guide

Testing Results: What Puppeteer Captcha Solver is quicker - Tokens vs. Clicks

I recorded the CAPTCHA solver extension using tokens and clicks, combined them into one video, and noted a few observations:

  1. Speed and Complexity: CAPTCHA bypassing speed depends on your IP address's spam history. Using proxies can improve speed and reduce costs.

  2. Quality of Proxies: With high-quality proxies, CAPTCHA may not even appear unless the system suspects bot activity.

Conclusion:

  • Token-Based CAPTCHA solving

    • Completion time: 18 seconds.

    • Sometimes faster, even under similar conditions.

  • Click-Based CAPTCHA bypass

    • Completion time (1st extension): 1 minute 10 seconds.

    • Completion time (2nd extension): 4 minutes (with manual intervention).

Verdict: For my tasks, tokens proved faster and more reliable—at least when you bypass CAPTCHA using Puppeteer. I’ll try Selenium next time.

Tags:
Hubs:
If this publication inspired you and you want to support the author, do not hesitate to click on the button
Total votes 1: ↑1 and ↓0+3
Comments0

Articles