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.
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/');
...
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With