Trouble with endless Cloudflare human verification in Puppeteer JavaScript

I’m having issues with Puppeteer and Cloudflare’s human verification. It keeps looping, even when I try to solve it by hand or use a bypass extension. This used to work fine before.

I think it might be related to proxy or captcha-solving extensions. I’ve noticed similar problems in regular Chrome after adding certain extensions.

Here’s what I’ve tried:

  • Running Puppeteer with different browsers (Chrome, Chromium, Brave, Opera)
  • Setting custom user agents and headers
  • Clearing cache and cookies
  • Using puppeteer-extra and puppeteer-extra-plugin-stealth

Here’s a basic version of my code:

const puppeteerExtra = require('puppeteer-extra');
const Stealth = require('puppeteer-extra-plugin-stealth');

puppeteerExtra.use(Stealth());

(async () => {
  const browser = await puppeteerExtra.launch({
    headless: false,
    args: ['--proxy-server=myproxy.example.com:8080'],
  });

  const page = await browser.newPage();

  await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36');
  await page.setExtraHTTPHeaders({
    'Accept-Language': 'en-US,en;q=0.9',
  });

  await page.authenticate({
    username: 'proxyuser',
    password: 'proxypass',
  });

  await page.goto('https://example.com/login', {
    waitUntil: 'networkidle2',
    timeout: 0,
  });

  await page.type('#email', '[email protected]');
  await page.type('#password', 'mypassword');
  await page.click('#login-button');

  await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 0 });

  await page.screenshot({ path: 'result.png' });
})();

I’m stuck on the Cloudflare page, which keeps looping even after manual solving. Any ideas on how to fix this?

I’ve encountered similar challenges with Cloudflare. One effective approach I’ve found is to implement browser fingerprinting techniques. This involves mimicking real browser characteristics, including screen resolution, available fonts, and installed plugins. Additionally, consider adding humanlike behavior patterns, such as random mouse movements and scroll events. These methods can help your requests appear more organic to Cloudflare’s detection systems. It’s also worth exploring alternative headless browser solutions like Playwright, which might handle Cloudflare’s challenges differently. Lastly, ensure your network setup isn’t flagged as suspicious; sometimes, VPN endpoints can trigger additional verifications.

yo, i had the same issue. cloudflare’s gotten smarter lately. try rotating IPs more often and use residential proxies. also, add some random delays between actions. maybe tweak ur useragent strings too. good luck man, CF’s a real pain in the ass these days

I’ve been battling with Cloudflare for months now, and I feel your pain. One thing that’s worked wonders for me is using undetected-chromedriver. It’s specifically designed to bypass these pesky detection mechanisms. Also, I’ve found that adding a bit of randomness to my browsing patterns helps. Things like varying the time between clicks, occasionally moving the mouse, and even adding some scrolling behavior. Oh, and don’t underestimate the power of good proxies - I’ve had success with rotating residential IPs. It’s not foolproof, but it’s definitely improved my success rate. Keep at it, and remember that Cloudflare is always evolving, so what works today might not work tomorrow. Stay vigilant and keep experimenting!