我正在尝试使用 cron
启动 chromedriver
session
我不断收到此错误:
(unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/lib/chromium-browser/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=71.0.3578.98,platform=Linux 4.15.0-45-generic x86_64)
如果我从 Pycharms 运行,效果很好
options = Options()
options.add_argument('--no-sandbox')
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver", options=options)
我尝试了很多事情,例如:
options.add_argument("--headless")
但它在 cron
中不起作用。
最佳答案
(代表问题作者发布解决方案,将其移至答案空间)。
发现问题了。
基本上cron
不知道在哪里显示。所以我们需要在 crontab 中告诉它在哪里显示,即
export DISPLAY=:0;
您需要使用 grep
查找 :0
部分。
不要忘记;
。
关于python - Selenium chromedriver 从 cron 作业失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61788361/