Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Puppeter-2.1.1,最新版本不适用于代理_Node.js - Fatal编程技术网

Node.js Puppeter-2.1.1,最新版本不适用于代理

Node.js Puppeter-2.1.1,最新版本不适用于代理,node.js,Node.js,上面的代码适用于Puppeter版本1.18.0,但在版本2.1.1中失败并给出以下错误 错误:net::ERR_无效_参数由于某些原因,在chromium和Puppeter的较新版本中,禁止设置其他标头(如主机)中的“代理授权” 使用没有此类限制的旧软件版本,例如。 在Chromium和Puppeter的较新版本中,由于某些原因,禁止在其他头文件(如主机)中设置捆绑Chromium 76.x的Puppeter 1.17“代理授权” 使用没有此类限制的旧软件版本,例如。 木偶演员1.17,捆

上面的代码适用于Puppeter版本1.18.0,但在版本2.1.1中失败并给出以下错误 错误:net::ERR_无效_参数

由于某些原因,在chromium和Puppeter的较新版本中,禁止设置其他标头(如主机)中的“代理授权”

使用没有此类限制的旧软件版本,例如。 在Chromium和Puppeter的较新版本中,由于某些原因,禁止在其他头文件(如主机)中设置捆绑Chromium 76.x的Puppeter 1.17“代理授权”

使用没有此类限制的旧软件版本,例如。 木偶演员1.17,捆绑铬76.x

    Running puppeteer with Proxy Authorization failing.

    Puppeteer version: 2.1.1

    const puppeteer = require('puppeteer');
    // Function to call proxy url
    (async () => {
        try {`enter code here`
          let data = [];
          let options = {
            headless: false,
            ignoreHTTPSErrors: true,
            slowMo: 134,
            devtools: true,
            args: [
            '--no-sandbox',
            '--auto-open-devtools-for-tabs',
            '--disable-setuid-sandbox',
            '--disable-dev-shm-usage',
            '--disable-accelerated-2d-canvas',
            '--disable-gpu',
            '--window-size=1920x1200',
            '--proxy-server=proxy.crawlera.com:8010',// proxy url
            '--ignore-certificate-errors',
            '--ignore-certificate-errors-spki-list'
            ]
          }

          const browser = await puppeteer.launch(options);
          let page = await browser.newPage();
          await page.setUserAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
          await page.setViewport({ width: 1920, height: 1200 });
          const key = '<My API Key>:';
          await page.setExtraHTTPHeaders({
              'Proxy-Authorization': 'Basic ' + Buffer.from(key).toString('base64'),
          });
          return [];
        } catch (e) {
          return e;
        }
    })();