尝试在 Node.js/Puppeteer 中使用代理服务器时出错

尝试在 Node.js/Puppeteer 中使用代理服务器时出错

问题描述:

我试图在我的 Node.js/Puppeteer 应用程序中使用代理并收到错误.

I am attempting to use a proxy within my Node.js / Puppeteer application and receiving errors.

如果我删除代理代码,应用程序将按预期运行.

If I remove the proxy code, the application runs as intended.

const browser = await puppeteer.launch({args: ['--proxy-server=socks5://127.0.0.1:9050'], headless: false});

我希望应用程序能像往常一样运行,但使用不同的 IP.

I expect the application to run as usual, but with a different IP.

收到错误:ERR_PROXY_CONNECTION_FAILED

Error received: ERR_PROXY_CONNECTION_FAILED

要么您的代理不起作用,要么 puppeteer 拒绝它,因为它很可能使用自签名证书.要修复证书问题,请添加以下参数.

Either your proxy is not working or puppeteer is rejecting it because it is most likely using a self-signed cert. To fix a cert issue add the following args.

args: [
    '--proxy-server=socks5://127.0.0.1:9050'
    '--ignore-certificate-errors',
    '--ignore-certificate-errors-spki-list '
]

参见:https://github.com/GoogleChrome/puppeteer/issues/1159一个>