我有可在 chromedriver 上运行的 selenium 解析器。当我在 bash 中启动它时,效果很好。但是当我开始服务时。它返回
The version of chrome cannot be detected. Trying with latest driver version
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
我尝试更改 PATH 变量并检查我的 chrome 是否是最新版本。
我在 macOS 上从 cronjob 运行 python 脚本时遇到了同样的问题。我必须修改
PATH
环境变量,以便脚本可以运行:
PATH=/opt/homebrew/bin:/usr/bin python3 ...
但是速度非常慢,每次运行都会弹出相同的
The version of chrome cannot be detected
错误。
我的解决方案是将
/bin
添加到 PATH
。 cron 作业现在看起来像这样
PATH=/opt/homebrew/bin:/usr/bin:/bin python3 ...
错误消息消失了,脚本现在速度更快了。希望这对你也有帮助。
将本指南留在这里,以防其他人有同样的问题。
https://dev.to/bailon/how-to-set-up-selenium-as-a-linux-daemon-with-systemd-4bdc