傀儡师代理



我正在尝试将木偶师与我自己的代理一起使用,但我似乎无法让它工作。 我的代理如下所示:

import * as h from 'http';
import * as hp from 'http-proxy';
import * as url from 'url';
const proxy = hp.createProxyServer({});
proxy.on('proxyReq', function (proxyReq, req, res, options) {
res.setHeader("Derp", "1231");
});
proxy.listen(8899);
h.createServer(function (req, res) {
const reqUrl = url.parse(req.url);
const targetHost = reqUrl.protocol + "//" + reqUrl.host;
proxy.web(req, res, { target: targetHost });
}).listen(3111);

然后当我启动浏览器时,我给出以下属性

const baseOptions: LaunchOptions = {
args:
[
"--no-sandbox",
"--disable-setuid-sandbox",
`--proxy-server=localhost:3111`,
],
timeout: 0,
ignoreHTTPSErrors: true
};

它在goto命令上失败,并显示以下错误

Error: net::ERR_EMPTY_RESPONSE at http://natashaskitchen.com/
at navigate (.../node_modules/puppeteer/lib/Page.js:598:37)
at process._tickCallback (internal/process/next_tick.js:68:7)

如果有人有任何建议,他们将不胜感激,谢谢!

您必须使用page.authenticate()来验证您的代理

https://pptr.dev/#?product=Puppeteer&version=v1.18.1&show=api-pageauthenticatecredentials

这就是我将木偶师与经过身份验证的代理一起使用的方式,效果很好!

const launchConfig = {
headless: true,
ignoreHTTPSErrors: true,
args: [`--proxy-server=11.321.4.23:8080`],
};
const browser = await puppeteer.launch(launchConfig);
const page = await browser.newPage();
await page.authenticate({
username: 'brucewayne',
password: 'darkknight',
});

最新更新