Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to use proxy with puppeteer. Error: ERR_NO_SUPPORTED_PROXIES gets thrown

How to set up a proxy with puppeteer? I tried the following:

(async () => {
    const browser = await puppeteer.launch({
        headless: false,
        args: [
            '--proxy-server=http://username:[email protected]:22225'
        ]
    });
    const page = await browser.newPage();
    await page.goto('https://www.whatismyip.com/');
    await page.screenshot({ path: 'example.png' });

    //await browser.close();
})();

But it does not work and I get the message:

Error: net::ERR_NO_SUPPORTED_PROXIES at https://www.whatismyip.com/

on the console. How to use the proxy correctly?

I also tried the following:

const browser = await puppeteer.launch({
        headless: false,
        args: [
            '--proxy-server=zproxy.luminati.io:22225'
        ]
    });

 const page = await browser.newPage();

 page.authenticate({
        username: 'username',
        password: 'password'
 })

 await page.goto('https://www.whatismyip.com/');

but the same result.

like image 298
Jatt Avatar asked Mar 20 '18 05:03

Jatt


1 Answers

Chrome can not handle username and password in proxy URLs. The second option which uses page.authenticate should work

(async () => {
  const browser = await puppeteer.launch({
        headless: false,
        args: [
            '--proxy-server=zproxy.luminati.io:22225'
        ]
    });

 const page = await browser.newPage();

 // do not forget to put "await" before async functions
 await page.authenticate({        
        username: 'username',
        password: 'password'
 })

 await page.goto('https://www.whatismyip.com/');
 ...
})();
like image 79
0x4a6f4672 Avatar answered Oct 17 '22 07:10

0x4a6f4672