Python + Splinter: Error - httplib.坏状态线:



在我的python项目中,我正在使用Splinter(https://splinter.readthedocs.io/en/latest/(打开浏览器,并尝试访问网站:

from splinter import Browser
browser = Browser('chrome')
browser.visit('http://www.google.com')

,浏览器打开了,并且没有能力访问http://www.google.com,它会有以下错误:

Traceback (most recent call last):
  File "practice.py", line 90, in <module>
    browser = Browser('chrome')
  File "/Library/Python/2.7/site-packages/splinter/browser.py", line 63, in Browser
    return driver(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/splinter/driver/webdriver/chrome.py", line 31, in __init__
    self.driver = Chrome(chrome_options=options, **kwargs)
  File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 98, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 185, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 247, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/remote_connection.py", line 464, in execute
    return self._request(command_info[0], url, body=data)
  File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/remote_connection.py", line 488, in _request
    resp = self._conn.getresponse()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1132, in getresponse
    response.begin()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 417, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''

奇怪的是,它在另一台Mac计算机上工作,但是当我将其传输到另一台Mac计算机时,遇到了该错误。

进行了研究,但无法说明真正的问题是什么。我会做错什么?我应该如何解决这个问题?

预先感谢您,并一定会赞扬/接受答案

您描述的症状与过时的Chromedriver 。转到" Chromedriver下载"页面,然后下载最新的驱动程序。对于当前最新的稳定Chrome 58,您需要chromedriver 2.29。

请注意,要检查chromedriver版本,执行:

$ chromedriver --version

,而且,请确保您拥有最新的splinterselenium

$ pip install -U splinter selenium

相关内容

  • 没有找到相关文章

最新更新