如何使用经过身份验证的代理启动 chrome 并使用 puppeteer 对其进行身份验证

how to launch chrome with an authenticated proxy and authenticate them with puppeteer

因此使用这些标志启动 chrome 实例;

`chrome --remote-debugging-port=${port}   --user-data-dir="C:\Users\USER\AppData\Local\Google\Chrome\User Data  --proxy-server=http://host:port`

并且代理是私有的,有用户名和密码可以使用,

我尝试将一个 puppeteer 实例连接到那个 chrome 并使用 puppeteer 进行身份验证,但这似乎不起作用

const browserURL = `http://127.0.0.1:9222`;
const browser = await puppeteer.connect({browserURL, defaultViewport : null });
const page = await browser.newPage();
let username = "username"
let password = "password"
await page.authenticate({
  username: username,
  password: password,
});

您可以尝试使用 HTTP headers 而不是 page.authenticate:

await page.setExtraHTTPHeaders({
    'Proxy-Authorization': 'username:password',
});

请参阅您的代理文档,了解 headers 的名称以及如何对其进行正确编码。