ZFC-Digital / puppeteer-real-browser

This package is designed to bypass puppeteer's bot-detecting captchas such as Cloudflare. It acts like a real browser and can be managed with puppeteer.
https://www.npmjs.com/package/puppeteer-real-browser
MIT License
814 stars 96 forks source link

Linux non headless not working #54

Closed 0-don closed 4 months ago

0-don commented 6 months ago

Why doesn't it open the Chrome window on Linux? I saw your preview video, and you did screenshots on interval. Isn't there a better way just for debugging purposes? Afterwards, using headless as normal would be better.

import { connect } from "puppeteer-real-browser";

connect({
  headless: false,
  turnstile: true,
})
  .then(async (response) => {
    const { browser, page } = response;

    setInterval(async () => {
      await page.screenshot({ path: "./page.jpg" });
    }, 250);
    await page.goto("https://disboard.org/");
  })
  .catch((error) => {
    console.log(error.message);
  });
[don@arch pup]$ node index.mjs 
[ERROR] [PUPPETEER-REAL-BROWSER] | This library is stable with headless: true in linuxt environment and headless: false in Windows environment. Please send headless: 'auto' for the library to work efficiently.
mdervisaygan commented 5 months ago

In fact, the browser opens, but you can't see it because it is launched on a virtual screen. Thanks to xvfb, on Linux operating systems we can launch the browser on a virtual screen instead of on our own screen. The library takes advantage of this feature. If you delete the following section from the library, browsers will appear. https://github.com/zfcsoftware/puppeteer-real-browser/blob/dc173d62c0634e2d273bf6ac35d7afc1e47e1ed8/src/module/chromium.js#L57

If you are talking about the headless feature, it does not work except false. This is because Chrome disables some window properties when new and true. It can be used but not recommended as it will be detected.

https://stackoverflow.com/questions/68289474/selenium-headless-how-to-bypass-cloudflare-detection-using-selenium

0-don commented 5 months ago

Thanks for the explanation about Xvfb. It seems to work with headless: false on Windows, showing the screen. I know this increases detection risk, but it would be nice to have an option to toggle Xvfb for debugging on other pages in linux.