Puppeteer page.authenticate прокси https не работает - PullRequest
0 голосов
/ 17 сентября 2018

Запуск кукловода с ошибкой проверки подлинности прокси.

Версия кукловода: 1,8

Версия платформы / ОС: MacOS 10.13.6

Node.js версия: v10.9.0

    const puppeteer = require('puppeteer');

    (async () => {
        const browser = await puppeteer.launch({
        headless:false,
        ignoreHTTPSErrors:true,
        devtools:true,
        timeout:3000,
        args: ['--no-sandbox','--proxy-server=xxx:xxx']
     });
     const user='xxx';
     const password='xxx';
     const page = await browser.newPage();
     // await page.setExtraHTTPHeaders({
     //   'Proxy-Authorization': 'Basic ' + Buffer.from(`${user}:${password}`).toString('base64'),
   // });
     await page.authenticate({username:user, password:password});
     await page.goto('https://www.apple.com/');
     let title = await page.title();
     console.log("title:" + title);
     await browser.close();
    })();

получил ошибку:

(node:5858) UnhandledPromiseRejectionWarning: 
Error: net::ERR_TUNNEL_CONNECTION_FAILED at https://www.apple.com/
at navigate (/xxx/node_modules/_puppeteer@1.8.0@puppeteer/lib/Page.js:622:37)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:5858) UnhandledPromiseRejectionWarning:
Unhandled promise rejection. This error originated either by throwing
inside of an async function without a catch block, 
or by rejecting a promise which was not handled with .catch(). 
(rejection id: 1)

1 Ответ

0 голосов
/ 20 сентября 2018
const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({
    headless:false,
    ignoreHTTPSErrors:true,
    devtools:true,
    timeout:3000,
    args: ['--no-sandbox','--proxy-server=https=xxx:xxx']
 });
 const user='xxx';
 const password='xxx';
 const page = await browser.newPage();
 await page.authenticate({username:user, password:password});
 await page.goto('https://www.apple.com/');
 let title = await page.title();
 console.log("title:" + title);
 await browser.close();
})();

Для меня это сработало, добавив https между аргументом прокси-сервера.

...