硒不从事靴子覆盆子Pi

发布于 2025-02-04 02:46:12 字数 479 浏览 2 评论 0原文

因此,我有一个小的以下脚本:

from selenium import webdriver
import time

time.sleep(60)
with open('readme.txt', 'w') as f:
    f.write('Create a new text file!')
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
driver.get("https://mediamere.com")

问题是它创建一个文件,但没有打开网页。该脚本在我的crontab文件中使用此行调用:

@reboot python/home/pi/test.py.py

有人知道为什么我的网页不打开吗? 奇怪的是,如果我自己使用python/home/pi/test.py(在启动系统后),它的工作正常

So I have the small following script:

from selenium import webdriver
import time

time.sleep(60)
with open('readme.txt', 'w') as f:
    f.write('Create a new text file!')
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
driver.get("https://mediamere.com")

The issue is that it creates a file, but doesn't open the web page. The script is called using this line in my crontab file:

@reboot python /home/pi/test.py

Does anybody know why my web page is not opening?
What's also weird is that if I call it myself using python /home/pi/test.py (after the system is booted) it works fine

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉南桥 2025-02-11 02:46:12

看来您只将Web Driver传递给该功能。您需要通过.exe-file。也许尝试绝对的道路。

from selenium import webdriver
import time

time.sleep(60)
with open('readme.txt', 'w') as f:
    f.write('Create a new text file!')
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver/chromedriver.exe")
driver.get("https://mediamere.com")

It seem you passed no webdriver to the function just the path. You need to pass the .exe-file. And maybe try the absolute path.

from selenium import webdriver
import time

time.sleep(60)
with open('readme.txt', 'w') as f:
    f.write('Create a new text file!')
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver/chromedriver.exe")
driver.get("https://mediamere.com")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文