Selenium 2.53.5 httplib.BadStatusLine:&x27';python

Selenium 2.53.5 httplib.BadStatusLine:&x27';python,python,selenium,selenium-chromedriver,httplib,Python,Selenium,Selenium Chromedriver,Httplib,我正在尝试使用Python 2.7中的Selenium 2.53.5以在线形式自动注册序列号。该脚本已经运行了2个多月,但昨天我在运行它时开始收到一个错误:httplib.BadStatusLine:“”。有没有已知的修复方法?我已经读到,前导/尾随的新行字符可能会扰乱url的检索,但我似乎无法确定问题所在 代码: 错误: Traceback (most recent call last): File "automate.py", line 90, in <module>

我正在尝试使用Python 2.7中的Selenium 2.53.5以在线形式自动注册序列号。该脚本已经运行了2个多月,但昨天我在运行它时开始收到一个错误:httplib.BadStatusLine:“”。有没有已知的修复方法?我已经读到,前导/尾随的新行字符可能会扰乱url的检索,但我似乎无法确定问题所在

代码:

错误:

Traceback (most recent call last):
  File "automate.py", line 90, in <module>
    main()
  File "automate.py", line 85, in main
    newSet = SerialSet(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
  File "automate.py", line 11, in __init__
    self.driver = webdriver.Chrome(driverPath)
  File "/Library/Python/2.7/site-    packages/selenium/webdriver/chrome/webdriver.py", line 67, in __init__
    desired_capabilities=desired_capabilities)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
response = self.command_executor.execute(driver_command, params)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 401, in execute
return self._request(command_info[0], url, body=data)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 432, 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: ''
回溯(最近一次呼叫最后一次):
文件“automatic.py”,第90行,在
main()
文件“automation.py”,第85行,主
newSet=SerialSet(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4])
文件“automatic.py”,第11行,在_init中__
self.driver=webdriver.Chrome(driverPath)
文件“/Library/Python/2.7/site-packages/selenium/webdriver/chrome/webdriver.py”,第67行,在__
期望的_能力=期望的_能力)
文件“/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py”,第90行,在__
self.start\u会话(所需的\u功能、浏览器\u配置文件)
文件“/Library/Python/2.7/site packages/selenium/webdriver/remote/webdriver.py”,第177行,在启动会话中
响应=self.execute(Command.NEW_会话,功能)
文件“/Library/Python/2.7/site packages/selenium/webdriver/remote/webdriver.py”,执行中的第234行
响应=self.command\u executor.execute(driver\u command,params)
文件“/Library/Python/2.7/site packages/selenium/webdriver/remote/remote_connection.py”,第401行,在execute中
返回self.\u请求(命令信息[0],url,正文=数据)
文件“/Library/Python/2.7/site packages/selenium/webdriver/remote/remote\u connection.py”,第432行,在请求中
resp=self.\u conn.getresponse()
getresponse中的文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第1132行
response.begin()
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,begin中第453行
版本、状态、原因=self.\u读取\u状态()
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第417行,处于“读取”状态
升起状态行(行)
httplib.BadStatusLine:“”

确保您使用的是最新版本的chromedriver:

我安装了chromedriver 2.0,出现了这个错误


当我升级到2.25时,它消除了这个错误。

看起来他们很难重现这个问题:Chromedriver是在2016年10月22日更新的。如果它在那之前工作,但在那之后没有工作,那么更新chromedriver可能会解决它。这仍然没有解决我的问题,在chrome尝试加载第一个网页后,我仍然收到httplib.BadStatusLine错误。起初,您在调用chromedriver时收到httplib错误,现在,当您尝试加载第一页时会发生这种情况?可能是该网站发送了错误的请求,您是否尝试加载其他网站,如google.com?还是bing.com?我只是想确认一下,这个网站可能会发送一个糟糕的报告
Traceback (most recent call last):
  File "automate.py", line 90, in <module>
    main()
  File "automate.py", line 85, in main
    newSet = SerialSet(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
  File "automate.py", line 11, in __init__
    self.driver = webdriver.Chrome(driverPath)
  File "/Library/Python/2.7/site-    packages/selenium/webdriver/chrome/webdriver.py", line 67, in __init__
    desired_capabilities=desired_capabilities)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
response = self.command_executor.execute(driver_command, params)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 401, in execute
return self._request(command_info[0], url, body=data)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 432, 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: ''