作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 python 3.6 并使用最新版本的 chromedriver,我尝试使用旧版本的 chromedriver,我遇到了同样的问题,重新启动了我的电脑,同样的问题。这是我运行以重现错误的代码:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://google.com")
完整错误:
driver.get("https://google.com")
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in get
self.execute(Command.GET, {'url': url})
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 254, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 464, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 488, in _request
resp = self._conn.getresponse()
File "C:\Python36\lib\http\client.py", line 1331, in getresponse
response.begin()
File "C:\Python36\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Python36\lib\http\client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Python36\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
最佳答案
在 driver.get("https://google.com ") 之前放入 time.sleep(3),这将修复您的错误。那么如果你像我一样,你会得到一个不同的错误。
关于Python Selenium ConnectionResetError : [WinError 10054] An existing connection was forcibly closed by the remote host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45342383/
我是一名优秀的程序员,十分优秀!