首页 > 解决方案 > 无法在 selenium chromedriver 上添加超过 20 个扩展

问题描述

我正在使用这段代码:

chrome_options.add_extension(r'path to extension 1')
chrome_options.add_extension(r'path to extension 2')
...
chrome_options.add_extension(r'path to extension 20')


driver =  webdriver.Chrome(executable_path = r"C:\chromedriver.exe" , chrome_options=chrome_options)

出于某种原因,我想向 chrome 添加 100 个扩展,但是当我添加超过 20 个扩展时,我看到了这个错误:

 driver =  webdriver.Chrome(executable_path = r"C:\chromedriver.exe" , chrome_options=chrome_options)
Traceback (most recent call last):
  File "C:\Users\vanzw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\vanzw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\vanzw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\vanzw\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1322, in getresponse
    response.begin()
  File "C:\Users\vanzw\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 303, in begin
    version, status, reason = self._read_status()
  File "C:\Users\vanzw\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 264, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\vanzw\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

我究竟做错了什么?我怎样才能绕过这个 20 的限制,是什么导致了这个限制?

标签: pythongoogle-chrome-extensionselenium-chromedriver

解决方案


我一直无法完全解决这个问题,但我发现 20 扩展限制在某种程度上与 Windows 20 套接字限制有关: https ://forum.powerbasic.com/forum/user-to-user-discussions/programming-the -internet/771798-maximum-unique-tcp-connections-allowed-by-license-in-windows-10


推荐阅读