提问者:小点点

macOS 11.1 Big Sur上的Puppeteer和无头铬爬虫


在安装了macos11.1(Big Sur)的Intel MacBook Pro上运行Headless Chrome Crawler(hccrawler)时,会出现以下错误:

hccrawler:console error Failed to load resource: net::ERR_FAILED at https://example.com/some-page
(node:12722) UnhandledPromiseRejectionWarning: Error: Page crashed!
    at Page._onTargetCrashed (./node_modules/puppeteer/lib/Page.js:156:24)
    at CDPSession.Page.client.on.event (./node_modules/puppeteer/lib/Page.js:132:56)
    at CDPSession.emit (events.js:198:13)
    at CDPSession.EventEmitter.emit (domain.js:448:20)
    at CDPSession._onMessage (./node_modules/puppeteer/lib/Connection.js:232:12)
    at Connection._onMessage (./node_modules/puppeteer/lib/Connection.js:119:19)

注意:为了获得更详细的日志,我使用了环境变量。

版本:

在以前版本的macOS和Ubuntu上,它仍然可以毫无问题地工作。知道问题出在哪里吗?会不会是最新的macOS版本在某种程度上阻止了由puppeteer产生的铬处理呢?


共1个答案

匿名用户

升级到headless-chrome-crawler(master branch)的最新版本解决了这个问题。将以下内容添加到您的package.json文件中:

"headless-chrome-crawler": "git://github.com/yujiosaka/headless-chrome-crawler.git#f4004f6f1a27534222703f9161f44815c8eefbe3"

"headless-chrome-crawler": "git://github.com/yujiosaka/headless-chrome-crawler.git#master"

这将把Puppeteer 1.20.0和Chromium r686378安装到您的node_modules中。

注意:在您阅读本文的时候,可能已经有了HCC&>的新版本;1.8.0,因此您可能只能够执行

还要注意,您可以使用自定义Chromium路径作为传递给的选项的一部分,这对于调试或快速试用其他版本很有用:

hccrawler.launch({
  // ...
  executablePath: '/path/to/custom/Chromium.app/Contents/MacOS/Chromium'
});