zoukankan      html  css  js  c++  java
  • 搞node爬虫--puppeteer--记一次大坑

    解决办法:升级node,然后重新下载puppeteer插件

    设置淘宝镜像下载
    npm config set puppeteer_download_host=https://npm.taobao.org/mirrors

    npm install puppeteer

    问题:报错

    (node:828) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
    [0104/213745.484:ERROR:main_dll_loader_win.cc(109)] Failed to load Chrome DLL from E:
    ode学习
    ode_modulespuppeteer.local-chromiumwin64-818858chrome-winchrome.dll: �Ҳ���ָ����ģ�顣 (0x7E)
    TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
    
        at onClose (E:
    ode学习
    ode_modulespuppeteerlibcjspuppeteer
    odeBrowserRunner.js:193:20)
        at ChildProcess.<anonymous> (E:
    ode学习
    ode_modulespuppeteerlibcjspuppeteer
    odeBrowserRunner.js:184:79)
        at ChildProcess.emit (events.js:327:22)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:828) 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(). To terminate the node process on unhandled promise 
    rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection 
    id: 1)
    (node:828) [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.
    

     解决:

    官方:

    Chrome is downloaded but fails to launch on Node.js 14
    
    If you get an error that looks like this when trying to launch Chromium:
    
    (node:15505) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
    spawn /Users/.../node_modules/puppeteer/.local-chromium/mac-756035/chrome-mac/Chromium.app/Contents/MacOS/Chromium ENOENT
    
    This means that the browser was downloaded but failed to be extracted correctly. The most common cause is a bug in Node.js v14.0.0 which broke extract-zip, the module Puppeteer uses to extract browser downloads into the right place. The bug was fixed in Node.js v14.1.0, so please make sure you're running that version or higher. Alternatively, if you cannot upgrade, you could downgrade to Node.js v12, but we recommend upgrading when possible.
    

     翻译:

    Chrome已下载,但无法在上启动节点.js14
    
    
    如果在尝试启动Chromium时出现如下错误:
    
    
    (节点:15505)未处理的PromisejectionWarning:错误:无法启动浏览器进程!
    
    spawn/Users/../nodeu modules/puppeteer/.local chromium/mac-756035/chrome mac/Chromium.app/Contents/MacOS/Chromium文件依诺特
    
    
    这意味着浏览器已下载,但未能正确提取。最常见的原因是节点.js其中v14.0.0打破了解压zip,模组puppeter用来解压浏览器下载到正确的地方。qietingqi已修复节点.jsv14.1.0,所以请确保您运行的是该版本或更高版本。或者,如果您不能升级,您可以降级到节点.jsv12,但我们建议在可能的情况下升级。
    
  • 相关阅读:
    完整的开源和商业软件平台
    免费开源的文件比较/合并工具
    Javascript面向对象基础
    Javascript面向对象基础
    引入外部js获取dom为null的问题
    闭包函数
    初识对象
    构造函数
    内置对象
    Math对象
  • 原文地址:https://www.cnblogs.com/fdxjava/p/14232771.html
Copyright © 2011-2022 走看看