gajus / puppeteer-proxy

Proxies Puppeteer Page requests.
Other
197 stars 24 forks source link

I can't set up a proxy with a password. #21

Closed kurohoan closed 2 years ago

kurohoan commented 2 years ago

I want to set up a proxy with a password for multitasking, but the following code fails to set up the proxy and stops it from loading.

Can you tell me what is causing this?


var browser = [];
var pages = [];

for( let i=0; i < 3; i++ ){
  browser[i] = await puppeteer.launch(option);
  pages[i] = await browser[i].newPage();
}

for( let i=0; i < 3; i++ ){
  await pages[i].setRequestInterception(true);
  pages[i].on('request', async (request) => {
    if (request.resourceType() === 'image'){
      request.abort();
    }else{
      let proxy_fmt = 'http://user:pass@host:pass';
      await proxyRequest({
        page,
        proxyUrl: proxy_fmt,
        request,
      });
    }
  });
}
kurohoan commented 2 years ago

Does anyone have a clue about this problem?

kurohoan commented 2 years ago

Maybe it doesn't work on the following modules?

puppeteer-extra https://github.com/berstend/puppeteer-extra#readme

gajus commented 2 years ago

Sounds like you are using some other extensions that might be causing the problem.

restyler commented 1 year ago

Consider using another approach with proxy-chain npm package: https://pixeljets.com/blog/how-to-set-proxy-in-puppeteer/#my-preferred-approach-to-set-proxy-for-puppeteer