当前位置: 首页 > 面试题库 >

urllib3.exceptions.ProtocolError:('Connection aborted。',error(10054,'一个现有的连接被远程主机强行关闭')

夏意蕴
2023-03-14
问题内容

我正在尝试使用Python Selenium chromedriver在chrome上打开一个网站。Chrome浏览器正在打开(带有警告),并且网址未打开。

版本详细信息:Chrome:68.0.3440.106硒:3.14.0 chromedriver:2.20 python:2.7

我正在使用以下代码:

import time
from selenium import webdriver
import selenium
driver = webdriver.Chrome("C:/Python27/chromedriver.exe")
driver.get("https://vancouver.craigslist.ca/")
print(driver.title)
time.sleep(8)
driver.quit()

我得到以下错误:

C:\Users\sohil7777\PycharmProjects\temp.py\venv\Scripts\python.exe C:/Users/sohil7777/.PyCharmCE2018.2/config/scratches/scratch.py
Traceback (most recent call last):
  File "C:/Users/sohil7777/.PyCharmCE2018.2/config/scratches/scratch.py", line 6, in <module>
    driver = webdriver.Chrome("C:/Python27/chromedriver.exe")
  File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 318, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 375, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "C:\Python27\lib\site-packages\urllib3\request.py", line 72, in request
    **urlopen_kw)
  File "C:\Python27\lib\site-packages\urllib3\request.py", line 150, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "C:\Python27\lib\site-packages\urllib3\poolmanager.py", line 322, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Python27\lib\site-packages\urllib3\util\retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 377, in _make_request
    httplib_response = conn.getresponse(buffering=True)
  File "C:\Python27\Lib\httplib.py", line 1121, in getresponse
    response.begin()
  File "C:\Python27\Lib\httplib.py", line 438, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\Lib\httplib.py", line 394, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "C:\Python27\Lib\socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
urllib3.exceptions.ProtocolError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))

我想念什么吗?非常感谢您的帮助


问题答案:

此错误消息…

urllib3.exceptions.ProtocolError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))

…暗示 ChromeDriver 无法启动/产生新的 WebBrowser,Chrome浏览器 会话。

您的主要问题是所使用的二进制版本之间的 不兼容性 ,如下所示:

  • 您正在使用 chromedriver = 2.20
  • chromedriver = 2.20的 发行说明明确提到以下内容:

支持 Chrome v43-48

  • 您正在使用 chrome = 68.0
  • ChromeDriver v2.41的 发行说明中明确提到以下内容:

支持 Chrome v67-69

因此, ChromeDriver v2.33Chrome浏览器v65.0 之间存在明显的不匹配 __

  • 升级 ChromeDriver 当前 ChromeDriver V2.41 水平。
  • Chrome 版本保持在 Chrome v67-69 之间。(根据ChromeDriver v2.41发行说明)
  • 清理 你的 项目工作 ,通过你的 IDE重建 仅需要依赖你的项目。
  • 如果您的基本 Web客户端 版本太旧,则将其卸载并安装最新的GA和 Web客户端的 发行版本。
  • 执行您的@Test


 类似资料:
  • 问题内容: 我正在尝试使用Python Selenium chromedriver在chrome上打开一个网站。Chrome浏览器正在打开(带有警告),并且网址未打开。 版本详细信息:Chrome:68.0.3440.106selenium:3.14.0 chromedriver:2.20 python:2.7 我正在使用以下代码: 我得到以下错误: 我想念什么吗?非常感谢您的帮助 问题答案: 此

  • 问题内容: 我正在使用他们的托管页面集成功能与替代付款进行集成。他们的C#SDK目前没有可用的集成,但是您可以看到它非常简单,我制作了一个小类来发送发布请求并获取JSON响应。 我测试了我在PostMan和cURL上发送的json对象,它们都可以工作,也可以使用身份验证标头,所以我认为它们不是问题。这是我的课程的构造函数: 以及我发布数据的方法: 然后,我在PostAsync行收到此错误:。这是错

  • 有人能帮我解决以下异常吗, 我正在使用Oracle OEPE eclipse和weblogic 12c。在我开始开发移动应用程序之前,它工作得很好。 我在eclipse中安装了以下插件。1.Android工具2。JBoos混合移动工具 我的电脑1上安装了以下开源软件。节点Js 2。科尔多瓦3。Ripple仿真器

  • 我正在使用laravel,我想向我的邮件陷阱发送一封假电子邮件,但这就是我所拥有的: fwrite():发送6字节失败,错误号为10054远程主机已强制关闭现有连接。 ,或另一个错误显示: 预期响应代码为250,但得到的响应为空。 有时它只工作一次,返回到相同的错误请帮助我,我厌倦了这件事 这是我的smtp代码 我在用XAMPP

  • 正如我前面所说的,我能够在visual studio的调试模式下使其正确工作,但一旦创建了可执行文件,我就不能再读取网页了。如有任何帮助,我们将不胜感激。是什么导致了这个问题?