【发布时间】:2020-07-14 19:51:14
【问题描述】:
可能是一个新手问题,但我真的很难让 Puppeteer 工作。我可能在下载的某个地方搞砸了,但我就是想不通。
我的 puppeteer 版本是 5.1.0 节点是 v14.5.0 在 Ubuntu 18.04 上运行,但也无法在 Windows 命令行上运行 视窗 10
这是我的 package.json:
{
"name": "test_puppeteer",
"version": "1.0.0",
"description": "",
"main": "test.js",
"dependencies": {
"puppeteer": "^5.1.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
我尝试运行此测试,它适用于 example.com,但没有其他网站并且它没有正确关闭 这是我的基本截图测试:
var puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox']})
const page = await browser.newPage();
await page.goto('https://www.example.com');
await page.screenshot({path: 'example.png'});
await browser.close();
})();
如果我运行它,我会创建 example.png,但没有其他反馈,如果我将站点更改为其他任何内容,我会得到 (node:28737) UnhandledPromiseRejectionWarning: TimeoutError: Navigation timeout of 30000 ms exceeded
【问题讨论】:
标签: node.js windows ubuntu installation puppeteer