【问题标题】:Failing to Get Puppeteer to Work and Install无法让 Puppeteer 工作和安装
【发布时间】: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


    【解决方案1】:

    我是个傻瓜,答案在于我自己电脑的权限混乱。从长远来看可能不是很好,但是当我在桌面上的文件夹中运行 puppeteer 时,我没有问题,忽略这个!

    【讨论】:

      猜你喜欢
      • 2022-06-30
      • 1970-01-01
      • 2019-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多