gpt4 book ai didi

python - 来自 python selenium 脚本的回溯错误(间歇性工作)

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:24:15 25 4
gpt4 key购买 nike

我用 Python 编写了一个 selenium 脚本来自动发布到特定网站。我过去曾运行过它,它运行得非常完美。但是,我去运行脚本,现在突然收到以下内容。我相信这是模块以某种方式加载的问题。此外,有时 firefox 会打开,有时则不会。 Mac 上的 Linux。

脚本:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('https://losangeles.craigslist.org/')

错误:

/usr/bin/python2.7 /home/max/Desktop/CraigsList.py
Traceback (most recent call last):
File "/home/max/Desktop/CraigsList.py", line 4, in <module>
browser = webdriver.Firefox()
File "/home/max/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 81, in __init__
self.binary, timeout)
File "/home/max/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/home/max/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "/home/max/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 98, in _wait_until_connectable
raise WebDriverException("The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

最佳答案

  1. 尝试在控制台中运行 FF,使用与运行 python 脚本相同的用户和路径
  2. 为 webdriver 设置 log_file
  3. 也许最好使用 PhantomJS 驱动程序?

关于python - 来自 python selenium 脚本的回溯错误(间歇性工作),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37976045/

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