Cuadrix / puppeteer-page-proxy

Additional module to use with 'puppeteer' for setting proxies per page basis.
425 stars 99 forks source link

UseProxy at page-level and block custom request #13

Closed leoplct closed 4 years ago

leoplct commented 4 years ago

I have to use setRequestInterception() to block images/font/images and to proxy each new page. I tried to UseProxy() at request-level but it's too slow. How can I fix it?

await page.setRequestInterception(true);
  page.on('request', (req) => {

    if( 
        req.url().includes("images") || 
        req.resourceType() == 'stylesheet' || 
        req.resourceType() == 'font'       || 
        req.resourceType() == 'image'
    ){
      req.abort();
    }else {
      useProxy(req, `http://${ proxy_username }:${proxy_password}@host:port`); //<-- this is too slow
      //req.continue();
    }
  });
Cuadrix commented 4 years ago

Try v1.2.4