Integrating recaptcha solver with puppeteer-real-browser

Hey guys, I’m stuck with a problem. I used to work with puppeteer-extra and could easily handle captchas using the puppeteer-extra-plugin-recaptcha. But now I’ve switched to puppeteer-real-browser and I can’t figure out how to solve captchas anymore.

I’ve tried to use both libraries together, but it’s not working. Here’s a simplified version of what I’m trying to do:

import { connect } from 'puppeteer-real-browser';
import puppeteer from 'puppeteer-extra';
import RecaptchaPlugin from 'puppeteer-extra-plugin-recaptcha';

async function browsePage() {
  const { page, browser } = await connect(/* options */);
  
  puppeteer.use(RecaptchaPlugin({
    provider: { id: '2captcha', token: 'my_api_key' }
  }));
  
  // How do I use page.solveRecaptchas() here?
}

browsePage();

Any ideas on how to make this work? I really need to solve those captchas. Thanks!

hey luna, i had a similar issue. try using the RecaptchaPlugin directly on the page object instead of puppeteer. something like:

import { RecaptchaPlugin } from 'puppeteer-extra-plugin-recaptcha';
const recaptchaPlugin = RecaptchaPlugin({ provider: {...} });
await recaptchaPlugin.solve(page);

hope that helps! let me know if u need more info

I’ve encountered this issue as well when transitioning to puppeteer-real-browser. In my experience, the solution was to handle the captcha challenge independently rather than relying on the puppeteer-extra plugins. I switched to using a dedicated service such as 2captcha-node. Instead of trying to use a plugin on the page object, I integrated the solver as a separate module within my code. When a captcha appears, I send the challenge to the external solver, retrieve the solution, and then inject it into the page using page.evaluate. Although this requires extra manual coding, it proved to be a more reliable approach for my setup.

I’ve faced similar challenges when using puppeteer-real-browser. In my experience, the solution was to integrate a dedicated 2captcha API outside of any external plugins. I detected when a captcha appeared and extracted the necessary site key and parameters. I then sent a request to the 2captcha API and waited for the solution before inserting it into the page via page.evaluate. Although this required extra manual coding, it provided more control and reliability compared to using a plugin directly.