【问题标题】:Puppeteer error while running in ubuntu machine在 ubuntu 机器上运行时出现 Puppeteer 错误
【发布时间】:2021-05-20 14:15:56
【问题描述】:

当我在 Ubuntu 上运行 puppeteer 时出现此错误:

UnhandledPromiseRejectionWarning: Error: Unable to launch browser, error message: Failed to launch the browser process!
[2098647:2098647:0520/162023.317120:ERROR:vaapi_wrapper.cc(594)] Could not get a valid VA display
[2098647:2098647:0520/162023.317252:ERROR:gpu_init.cc(426)] Passthrough is not supported, GL is egl


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at Cluster.<anonymous> (/root/Desktop/Copart/node_modules/puppeteer-cluster/dist/Cluster.js:119:23)
    at Generator.throw (<anonymous>)
    at rejected (/root/Desktop/Copart/node_modules/puppeteer-cluster/dist/Cluster.js:6:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)

这是我的傀儡选项:

 pupOptions: {
    headless: false,
    args: [
      "--incognito",
      "--disable-gpu",
      "--disable-dev-shm-usage",
      "--disable-setuid-sandbox",
      "--no-first-run",
      "--no-sandbox",
      "--no-zygote",
    ],
    defaultViewport: null,
    slowMo: 10,
    sameDomainDelay: 1000,
    retryDelay: 3000,
    workerCreationDelay: 3000,
    timeout: 30000000,
    userDataDir: "/root/.config/google-chrome",
    executablePath: "/opt/google/chrome/google-chrome",
  }

另外,这里是我使用的插件:

const puppeteer = require("puppeteer-extra");
const RecaptchaPlugin = require("puppeteer-extra-plugin-recaptcha");

我尝试在运行代码之前杀死谷歌实例,但仍然没有工作

另外,我想提一下,它在使用“puppeteer-cluster”时有效

有人对此有任何想法或解决方案吗?非常感谢您的帮助!

【问题讨论】:

  • 你可能需要 headless:true 或者使用 xvfb-run 运行

标签: node.js web-scraping puppeteer puppeteer-cluster


【解决方案1】:

我不得不从 args 中删除“--disable-gpu”

【讨论】:

    猜你喜欢
    • 2020-12-06
    • 2017-04-27
    • 1970-01-01
    • 2020-08-15
    • 1970-01-01
    • 1970-01-01
    • 2020-10-05
    • 2015-09-08
    • 1970-01-01
    相关资源
    最近更新 更多