Skip to content

urllib.error.URLError: <urlopen error [WinError 10054] 远程主机强迫关闭了一个现有的连接。 #1431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
boboboomY opened this issue Jul 30, 2023 · 5 comments

Comments

@boboboomY
Copy link

Traceback (most recent call last):
File "C:\Program Files\Python311\Lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Program Files\Python311\Lib\http\client.py", line 1286, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files\Python311\Lib\http\client.py", line 1332, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files\Python311\Lib\http\client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files\Python311\Lib\http\client.py", line 1041, in _send_output
self.send(msg)
File "C:\Program Files\Python311\Lib\http\client.py", line 979, in send
self.connect()
File "C:\Program Files\Python311\Lib\http\client.py", line 1458, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Program Files\Python311\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\auto_goods\url_senti.py", line 4, in
driver = uc.Chrome() # 创建浏览器对象
^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Roaming\Python\Python311\site-packages\undetected_chromedriver_init_.py", line 247, in init
self.patcher.auto()
File "C:\Users\Administrator\AppData\Roaming\Python\Python311\site-packages\undetected_chromedriver\patcher.py", line 158, in auto
release = self.fetch_release_number()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Roaming\Python\Python311\site-packages\undetected_chromedriver\patcher.py", line 222, in fetch_release_number
return LooseVersion(urlopen(self.url_repo + path).read().decode())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10054] 远程主机强迫关闭了一个现有的连接。>

This is my code:

import undetected_chromedriver as uc

配置 ChromeOptions

driver = uc.Chrome() # 创建浏览器对象
driver.maximize_window() # 最大化浏览器窗口

@Etern213
Copy link

exactly same issue

1 similar comment
@imamong
Copy link

imamong commented Jul 31, 2023

exactly same issue

@imamong
Copy link

imamong commented Aug 1, 2023

找到了问题,本质上是程序会动态的去下载合适的chrome的驱动,然后进行patch,在连接 https://chromedriver.storage.googleapis.com/LATEST_RELEASE_113 这类页面的时候,会失败(墙的问题)

所以解决方法就是自己下载合适的驱动,然后指定驱动的路径。

driver = uc. Chrome(options=chrome_options, version_main='113',driver_executable_path= '/path/to/chromedriver.exe')

这样就可以用了。

@DeSireFire
Copy link

归根结底就是chromedriver的下载方式从115开始改变了。
114和以前的版本能通过拼接url路径的方式获取,现在115开始不行了。
undetected-chromedriver 在这点上没有更新自动下载driver的函数。

自己下一个试试

https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5763.0/win64/chromedriver-win64.zip

@Doujiang2333
Copy link

刚开始指定driver路径的时候用错关键词了,我说怎么指定了还要去下载

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants