zfcsoftware / 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
572 stars 78 forks source link

Request interception problem #141

Closed jairoxyz closed 2 weeks ago

jairoxyz commented 2 weeks ago

I wanted to use puppeteer-real-browser instead of puppeteer-core for my code but can't get request interception work the same way it does with standard puppeteer. I'm doing a basic injection of console.log statement in page javascript:

await page.setRequestInterception(true);
page.on('request', request => {
  request.respond({
    status: 200,
    body: oldbody + ';console.log("X: Some text");',
  });
});
....
return new Promise(async (resolve) => {
   page
      .on('console', async (message) => {
        let t = message.text();
        if (t.startsWith("X:")) {
            console.log(t);

This works fine in standard puppeteer but with real-browser it seems the modified body is passed to the response and the text is not logged to console.

Thanks,

Jx-

zfcsoftware commented 2 weeks ago

The console will not be accessible because the runtime is disabled. The puppeteer-core library was patched with rebrowser because the runtime caused too many leaks. Therefore the library does not support it. You can try to work with the Chrome plugin.