小编Ang*_*elo的帖子

在 WSL Ubuntu 上以 --headless --no 沙箱的形式运行“google-chrome”会出现多个错误 - 如何在 WSL 中使用 headless 截取屏幕截图?

我正在运行 Windows 10,并且一直在 Windows Linux 子系统下使用 Ubuntu Linux 发行版。

我希望能够使用 Chrome.exe 或 google-chrome 无头运行并截取屏幕截图、生成 pdf 等...作为库调用的一部分,但看不到这样做(例如,使用 jupyter_to_medium 库在截屏的背景)。

我已经尝试了多种方法来独立于我正在使用的库或程序使用 google-chrome 调试它。

这是我尝试过的:

  1. 可以通过 Ubuntu 终端启动 Chrome(Windows 可执行文件),并将其重定向到 Windows 可执行文件:

    /mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe
    
    Run Code Online (Sandbox Code Playgroud)

    当我这样做时,我的 Windows Chrome 浏览器中会打开一个新选项卡,所以这里没有问题。

  2. 当我尝试google-chrome在 ubuntu 终端中使用headless 时,我遇到了多个问题,例如

    2a) 尝试获取屏幕截图 -失败显示Network service crashed, restarting service无限循环 - 必须按 CTRL^C 来停止它

     (base) etzimopoulos@DESKTOP-HI9P6E4:~$ google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
    [0626/055458.471044:ERROR:udev_watcher.cc(61)] Failed to enable receiving udev events.
    [0626/055458.612113:ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting …
    Run Code Online (Sandbox Code Playgroud)

ubuntu google-chrome windows-subsystem-for-linux google-chrome-headless

8
推荐指数
1
解决办法
4851
查看次数