gpt4 book ai didi

python - 使用 Python Splinter 库时出错

转载 作者:行者123 更新时间:2023-12-01 05:40:03 26 4
gpt4 key购买 nike

我刚刚在我的 beaglebone 机器上安装了 Splinter python 库。当我使用 splinter 网站上提供的示例时,出现错误。我相信我需要安装网络驱动程序才能正常工作。

有人在命​​令行上为 beaglebone arm7 平台安装过任何 Web 驱动程序吗?

未修改的代码

from splinter import Browser

with Browser() as browser:
# Visit URL
url = "http://www.google.com"
browser.visit(url)
browser.fill('q', 'splinter - python acceptance testing for web applications')
# Find and click the 'search' button
button = browser.find_by_name('btnG')
# Interact with elements
button.click()
if browser.is_text_present('splinter.cobrateam.info'):
print "Yes, the official website was found!"
else:
print "No, it wasn't found... We need to improve our SEO techniques"

错误是

Traceback (most recent call last):
File "http1.py", line 3, in <module>
with Browser() as browser:
File "build/bdist.linux-armv7l/egg/splinter/browser.py", line 44, in Browser
File "build/bdist.linux-armv7l/egg/splinter/driver/webdriver/firefox.py", line 33, in __init__
File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 61, in __init__
self.binary, timeout),
File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 51, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 90, in _wait_until_connectable
self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: "The browser appears to have exited before we could connect. The output was: ERROR: ld.so: object 'x_ignore_nofocus.so' from LD_PRELOAD cannot be preloaded: ignored.\nError: no display specified\n"

最佳答案

可能有点太晚了,但以防万一:

我遇到了同样的问题,因为我没有安装 Firefox。 Splinter 基于 selenium,它使用 Mozilla Firefox 作为默认浏览器,因此:

  • 安装火狐浏览器

  • 下载 Chromedriver,以便 selenium (splinter) 可以通过 Google Chrome 浏览。看这个discussion有关设置 Chromedriver 的更多信息

希望对你有帮助!

关于python - 使用 Python Splinter 库时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17823628/

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