代码执行时收到的错误图像
下面是我使用的代码:proxy.js——
class Proxy
{
static create() {
return new Proxy();
}
this.browser = await puppeteer.launch({
args: [`--proxy-server=socks5:127.0.0.1:9150`, "--no-sandbox",
],
});
async newPage(newBrowser = false) {
/* Ensure a browser instance is present */
if (!this.browser) {
await this.launchNewBrowser();
}
/* Close all other pages/tabs */
await this.closePages();
}
connections.js(从这个文件调用)
const createTBrowser = require("..pathTo/proxy");
const Browser = createBrowser();
const page = await Browser.newPage();
await page.goto('Valid_URL');
代理不工作,因为木偶使用的是自签名证书,所以在参数中添加一个忽略标志可能会解决这个问题。
class Proxy {
static create() {
return new Proxy();
}
this.browser = await puppeteer.launch({
args: [
`--proxy-server=socks5:127.0.0.1:9150`,
"--no-sandbox",
"--ignore-certificate-errors",
"--ignore-certificate-errors-spki-list" ,
],
});
async newPage(newBrowser = false) {
/* Ensure a browser instance is present */
if (!this.browser) {
await this.launchNewBrowser();
}
/* Close all other pages/tabs */
await this.closePages();
}
}