How to make puppeteer work through socks5 proxy?
10,506
You can use page.authenticate()
to provide the credentials for your proxy.
For example:
'use strict';
const puppeteer = require('puppeteer');
(async () => {
const username = 'johndoe';
const password = 'qwerty1';
const browser = await puppeteer.launch({
args: [
'--proxy-server=socks5://proxyhost:8000',
],
});
const page = await browser.newPage();
await page.authenticate({
username,
password,
});
await page.goto('https://www.example.com/');
await browser.close();
})();
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on June 13, 2022Comments
-
Admin about 2 years
I bought a proxy server version of socsk5. In all manuals the same example
const browser = await puppeteer.launch({ headless: true, ignoreHTTPSErrors: true, defaultViewport: {...winSize}, args: [ '--proxy-server=socks5://proxyhost:8000', '--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE proxyhost"', ], })
It does not specify a login password for this proxy and it clearly does not work
If you specify this
'--proxy-server=socks5://user:password@proxyhost:8000',
it gives an error
net::ERR_NO_SUPPORTED_PROXIES
I tried with https://github.com/sjitech/proxy-login-automator build a bridge, but it did not work either.
Prompt please
-
wSkc over 5 yearsTested it with Tor ('--proxy-server=socks5://localhost:9050') and it worked flawlessly, thanks!
-
Gajus over 4 yearsNote that there are issues with proxy authentication when accessing HTTPS pages. github.com/puppeteer/puppeteer/issues/3253 You may want to try github.com/gajus/puppeteer-proxy