Node.js 木偶演员1.16.0可以';t导航到https://google.ca?

Node.js 木偶演员1.16.0可以';t导航到https://google.ca?,node.js,npm,puppeteer,Node.js,Npm,Puppeteer,运行npm audit fixfto修复漏洞后,Pupeter不再能够导航到任何东西,甚至连谷歌也不能 npm列表显示我正在使用1.16.0 在名为invoice\u to_pdf.js的脚本中: 2 const puppeteer = require('puppeteer'); ... 18 const headers = new Map(); ... 31 console.log("Starting " + new Date()); 32 33 34 (async () =

运行
npm audit fix
fto修复漏洞后,Pupeter不再能够导航到任何东西,甚至连谷歌也不能

npm列表显示我正在使用1.16.0

在名为
invoice\u to_pdf.js的脚本中:

  2 const puppeteer = require('puppeteer');
...
 18 const headers = new Map();
...
 31 console.log("Starting " + new Date());
 32 
 33 
 34 (async () => {
 35   const browser = await puppeteer.launch();
 36   const page = await browser.newPage();
 37   await page.setExtraHTTPHeaders(headers);
 38   page.setDefaultNavigationTimeout(50000)
 39 
 40   process.on("unhandledRejection", (reason, p) => {
 41             console.error("Unhandled Rejection at: Promise", p, "reason:", reason);
 42             browser.close();
 43             process.exit(1)
 44   });
 45 
 46   url = 'https://google.ca'
 47   console.log(`For testing, navigating to ${url}`);
 48   await page.goto(url);
 49   console.log(`Waiting for naviation to ${url}`);
 50   await page.waitForNavigation({waitUntil: 'load'});
 51   console.log(`Arrived at ${url}`);
 52 
输出为:

Starting Sun May 19 2019 22:23:18 GMT-0400 (EDT)
For testing, navigating to https://google.ca
Waiting for naviation to https://google.ca
Unhandled Rejection at: Promise Promise {
  <rejected> { TimeoutError: Navigation Timeout Exceeded: 50000ms exceeded
    at Promise.then (/home/jlam/code/sge/node_modules/puppeteer/lib/LifecycleWatcher.js:142:21)
    at <anonymous>
  -- ASYNC --
    at Frame.<anonymous> (/home/jlam/code/sge/node_modules/puppeteer/lib/helper.js:110:27)
    at Page.waitForNavigation (/home/jlam/code/sge/node_modules/puppeteer/lib/Page.js:649:49)
    at Page.<anonymous> (/home/jlam/code/sge/node_modules/puppeteer/lib/helper.js:111:23)
    at /home/jlam/code/sge/scripts/invoice_to_pdf.js:50:14
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7) name: 'TimeoutError' } } reason: { TimeoutError: Navigation Timeout Exceeded: 50000ms exceeded
    at Promise.then (/home/jlam/code/sge/node_modules/puppeteer/lib/LifecycleWatcher.js:142:21)
    at <anonymous>
  -- ASYNC --
    at Frame.<anonymous> (/home/jlam/code/sge/node_modules/puppeteer/lib/helper.js:110:27)
    at Page.waitForNavigation (/home/jlam/code/sge/node_modules/puppeteer/lib/Page.js:649:49)
    at Page.<anonymous> (/home/jlam/code/sge/node_modules/puppeteer/lib/helper.js:111:23)
    at /home/jlam/code/sge/scripts/invoice_to_pdf.js:50:14
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7) name: 'TimeoutError' }
谷歌从同一台机器上加载罚款:

lusk 22:30:12 $ lynx --dump google.ca

   Search [1]Images [2]Maps [3]Play [4]YouTube [5]News [6]Gmail [7]Drive
   [8]More »
   [9]Web History | [10]Settings | [11]Sign in

   Google

     _______________________________________________________
   Google Search  I'm Feeling Lucky    [12]Advanced search
      [13]Language tools

   Google offered in: [14]Français

   [15]Advertising Programs     [16]Business Solutions     [17]About
   Google     [18]Google.com

                      © 2019 - [19]Privacy - [20]Terms
你能试试吗

wait page.waitForNavigation({waitUntil:'networkidle2'})

而不是

wait page.waitForNavigation({waitUntil:'load'})
在此代码中:

 48   await page.goto(url);
 49   console.log(`Waiting for naviation to ${url}`);
 50   await page.waitForNavigation({waitUntil: 'load'});
。。。
waitForNavigation
不是必需的:

 64   url = 'https://google.ca'
 65   console.log(`For testing, navigating to ${url}`);
 66   await page.goto(url);
 67   console.log(`Arrived at ${url}`);
输出:

For testing, navigating to https://google.ca
Arrived at https://google.ca
wait
执行等待
goto
完成的任务

它有一个
页面。单击
必须使用
waitForNavigation
。我还看到了必须在调用
页面之前创建的引用(,)。单击

80   logInAwait = page.waitForNavigation({waitUntil: ['networkidle0', 'load', 'domcontentloaded']});
 81   await page.click('[name="commit"]')
 82   console.log("logging in....");
 83
... 
 87   await logInAwait

反馈最受欢迎,因为我不认为自己是JS专家。

当无头模式的转动时,你能检查你是否在导航?const浏览器=等待木偶程序。启动({无头:false,});我在{headless:false,}中看到了相同的输出。我正在通过远程连接执行,也许明天当我站在执行机器前面时,我会看到一些不同的东西。我运行了一个较小的脚本,并直接从命令行执行(OP是在bash脚本中调用的)。浏览器出现了,但我仍然得到相同的
,等待导航http://google.ca
直到我关闭浏览器:抱歉,我忘了在出现此问题时提到我们已经在使用networkidle2。我再次测试它只是为了确定是否发生了相同的超时行为:。我将尝试下一步关闭无头。
80   logInAwait = page.waitForNavigation({waitUntil: ['networkidle0', 'load', 'domcontentloaded']});
 81   await page.click('[name="commit"]')
 82   console.log("logging in....");
 83
... 
 87   await logInAwait