2 linqing360 linqing360 于 2017.07.17 12:11 提问

Python selenium 打开chrome error【10054】被强行关闭,请问如何解决? 5C
 from selenium import webdriver
import sys



sys.path.insert(0,'F:\浏览器\chome\Google\Chrome\Application')
options = webdriver.ChromeOptions()

options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])

driver = webdriver.Chrome(chrome_options=options)
driver.get('https://www.baidu.com')
driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()



with open('9.html','wb') as f:
    f.write(driver.page_source.encode('utf-8'))
    f.close()
driver.close()

运行后出现浏览器:这样的情况
图片说明
后代码报错:

Traceback (most recent call last):
  File "28baidu.py", line 12, in <module>
    driver.get('https://www.baidu.com')
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 254, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 464, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 488, in _request
    resp = self._conn.getresponse()
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1331, in getresponse
    response.begin()
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\linqing\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 586, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。


没想到在此入坑,折腾一天无果,请大神帮帮忙

2个回答

caozhy
caozhy   Ds   Rxr 2017.07.17 23:51
zy841958835
zy841958835   Rxr 2017.07.18 09:22

遇到过类似的问题 你可以换个google浏览器版本

Csdn user default icon
上传中...
上传图片
插入图片