gpt4 book ai didi

Python + split : Error - httplib. BadStatusLine: ''

转载 作者:太空狗 更新时间:2023-10-29 21:59:13 31 4
gpt4 key购买 nike

在我的 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 Downloads"页面并下载最新的驱动程序。对于当前最新的稳定版 Chrome 58,您需要 chromedriver 2.29。

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

$ chromedriver --version

此外,请确保您拥有最新的 splinterselenium:

$ pip install -U splinter selenium

关于Python + split : Error - httplib. BadStatusLine: '',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43649823/

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