javascript - Node.js puppeteer - 如何设置导航超时?

标签 javascript node.js puppeteer

我正在使用 node.js 和 puppeteer 来获取一些数据。我打开的一些文件非常大......然后我得到一个错误:

错误:

our error { TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
    at Promise.then (/project/node_modules/puppeteer/lib/NavigatorWatcher.js:74:21)
    at <anonymous> name: 'TimeoutError' }

如何忽略它或设置更高的超时时间?

这是我的脚本:

await page.goto('url'+tableCell04Val, {waitUntil: 'load'});

最佳答案

如果您正在加载一个沉重的页面,您可以使用 timeout: 0 来禁用超时错误。

在您的 page.goto 中使用它,例如:

await page.goto('url'+tableCell04Val, {waitUntil: 'load', timeout: 0});

You can see the PR made to Pupeteer here which added the change, along with documentation and the unit tests that implement it.

关于javascript - Node.js puppeteer - 如何设置导航超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52163547/

相关文章:

node.js - mongoDB:聚合 - 是否有等效于 native node.js 驱动程序的 $lookup 连接?

node.js - 使用 puppeteer 在 headless chrome 中运行 Flash 游戏

javascript - 使用 Document.querySelector 从 p 获取文本,不包括范围值

node.js - puppeteer 一起下载 firefox 和 chrome 二进制文件

javascript - new Date() 从无效输入字符串中生成有效日期

javascript - 使用kafka-node消费消息时接收垃圾字符

javascript - 使用具有自定义格式的时刻格式化日期

javascript - 与nodejs、mongoose 和 JSON 对象数组拼接

javascript - 报价和自动换行

javascript - 从 Backbone 集合中检索特定属性的列表