gpt4 book ai didi

ubuntu - 如何在服务器中运行 headful puppeteer?

转载 作者:行者123 更新时间:2023-12-03 20:50:33 52 4
gpt4 key购买 nike

我想用 headless = false 运行 puppeteer在我的带有 Ubuntu 的 Digital Ocean 服务器中。
当我进入 digitalocean.com 上的 Digital Ocean 控制台时,它运行正常(我将 ubuntu-desktop 作为 GUI,实际上会弹出 chromium 并开始在 GUI 中运行)。
但是,当我 ssh 进入控制台并尝试运行相同的程序时,程序会一直运行,直到它遇到 puppeteer 脚本,并且我从 puppeteer 收到以下错误消息:Error: Failed to launch the browser process!Unable to open X display.NaCl helper process running without a sandbox!Most likely you need to configure your SUID sandbox correctly这是我的 puppeteer 配置中的内容:

import puppeteer from "puppeteer";

export const getBrowser = async () => {
const browser = await puppeteer.launch({
headless: false,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--window-size=1600,1200",
],
defaultViewport: null,
});
return browser;
};
我玩过删除 --no-sandbox--disable-setuid-sandbox但这并没有解决它。
如果你问自己“他们为什么要这样做?” - 这主要是因为我发现我正在挖掘的网站在它处于头部状态时往往不会注意到它(我想我可以回到 puppeteer 隐身状态)。

最佳答案

我有同样的问题。我解决了一半。我在终端中启用了 X11 转发,现在一切都启动了。但是,我仍然在为此苦苦挣扎,因为我想在我的服务器上自动运行 headful 脚本而不受我的干扰,现在我正在思考我可以实现的方法。

关于ubuntu - 如何在服务器中运行 headful puppeteer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63126231/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com