【发布时间】:2019-03-03 09:31:50
【问题描述】:
我想用以下方法刮取元素#result 的value:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://dolartoday.com');
await console.log(page.evaluate(() => document.getElementById('result')));
await browser.close();
})();
但它仍然会记录以下错误:
(node:74908) UnhandledPromiseRejectionWarning: Error: Navigation Timeout Exceeded: 30000ms exceeded
at Promise.then (/Volumes/DATOS/Dropbox/workspaces/dolar-today/server/node_modules/puppeteer/lib/NavigatorWatcher.js:71:21)
at <anonymous>
(node:74908) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:74908) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
关于如何解决这个问题的任何想法?
【问题讨论】:
-
Navigation Timeout Exceeded: 30000ms exceeded
标签: javascript node.js web-scraping puppeteer