Puppeteer can't access HTTPS site with proxy server

女生的网名这么多〃 提交于 2021-01-29 15:42:59

问题


Here's my Nodejs code in which I'm trying to access a https site using https proxy but it doesn't seem to work, meanwhile the http proxy works fine. I have researched but nothing worked.

const puppeteer = require("puppeteer-extra");
const useProxy = require("puppeteer-page-proxy");
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
const AdblockerPlugin = require("puppeteer-extra-plugin-adblocker");
puppeteer.use(StealthPlugin());
puppeteer.use(AdblockerPlugin({ blockTrackers: true }));

(async () => {
    //proxies are from hidemy.name/en/proxy-list
    const proxy = {
        http: "http://89.187.177.91:80",
        https: "https://51.68.207.81:80",
    };
    const launchOptions = {
        executablePath: "/usr/bin/google-chrome",
        headless: false,
        args: [
            "--ignore-certificate-errors",
            "--disable-web-security",
            "--disable-setuid-sandbox",
            "--no-sandbox",
        ],
        ignoreHTTPSErrors: true,
    };

    const browser = await puppeteer.launch(launchOptions);
    const page = await browser.newPage();

    //not working
    //await useProxy(page, proxy.https);
    //const url = "https://www.google.com/";

    //working
     const url = "http://httpbin.org/get";
     await useProxy(page, proxy.http);

    await page.goto(url, { waitUntil: "domcontentloaded" });
    await useProxy(page, null);
    await page.waitForTimeout(4000);

    await page.wait;
    await page.close();
    await browser.close();
})();

来源:https://stackoverflow.com/questions/65372704/puppeteer-cant-access-https-site-with-proxy-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!