Puppeteer不会加载页面

时间:2018-01-10 12:06:54

标签: javascript puppeteer

我正在尝试使用puppeteer从此页面https://www.gsksaglik.com/internal-redirects.html获取请求,但似乎根本没有加载页面,因为浏览器不会关闭...

这是我的代码:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  page.on('request', (data) => console.log(data));
  page.on('requestfailed', (data) => console.log(data));
  page.on('requestfinished', (data) => console.log(data));
  await page.goto('https://www.gsksaglik.com/internal-redirects.html');

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

事件page.requestpage.requestfailedrequestfinised未被解雇

有谁知道为什么没有加载这个页面?

1 个答案:

答案 0 :(得分:0)

手动暂停

await page.goto('https://www.gsksaglik.com/internal-redirects.html', {
            networkIdleTimeout: 5000,
            waitUntil: 'networkidle',
            timeout: 3000000
        });

有关详情,请查看此链接https://github.com/GoogleChrome/puppeteer/issues/782