Reputation: 785
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.
Upvotes: 18
Views: 25254
Reputation: 681
Take care of quoting issues:
I had in Selenium (chromediver
, same arguments):
"--proxy-server='http://1.1.1.1:8888'"
This is wrong! This gives me the reported error.
You need:
"--proxy-server=http://1.1.1.1:8888"
Upvotes: 1
Reputation: 28245
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/');
...
})();
Upvotes: 19
Reputation: 44
After removing the double quotes from the args
worked fine for me.
https://github.com/puppeteer/puppeteer/issues/1074#issuecomment-359427293
Upvotes: 1
Reputation: 601
(async () => {
// install proxy-chain "npm i proxy-chain --save"
const proxyChain = require('proxy-chain');
// change username & password
const oldProxyUrl = 'http://lum-customer-USERNAMEOFLUMINATI-zone-static-country-us:[email protected]:22225';
const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl);
const browser = await puppeteer.launch({
headless: false,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
`--proxy-server=${newProxyUrl}`
]
});
const page = await browser.newPage();
await page.goto('https://www.whatismyip.com/');
await page.screenshot({ path: 'example.png' });
await browser.close();
})();
Upvotes: 22