【问题标题】:how to launch chrome with an authenticated proxy and authenticate them with puppeteer如何使用经过身份验证的代理启动 chrome 并使用 puppeteer 对其进行身份验证
【发布时间】:2021-06-10 12:44:58
【问题描述】:

所以使用这些标志启动一个 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,
});

【问题讨论】:

    标签: javascript node.js proxy puppeteer


    【解决方案1】:

    您可以尝试使用 HTTP 标头而不是 page.authenticate

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

    请参阅您的代理文档,了解标头的名称是什么,以及如何正确编码。

    【讨论】:

    • 我认为代理授权发送一个 base64 标头,谢谢我会尝试它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    • 1970-01-01
    • 2019-09-25
    • 1970-01-01
    • 2017-11-24
    • 2018-11-16
    • 2017-12-08
    相关资源
    最近更新 更多