gpt4 book ai didi

python - Selenium headless ChromeDriver 失败并出现 ConnectionResetError : [Errno 104] Connection reset by peer

转载 作者:行者123 更新时间:2023-11-28 18:10:59 28 4
gpt4 key购买 nike

<分区>

我有一个在 headless Debian (9) 服务器上使用 Selenium (3.12)、chromedriver (2.39) 和 Google Chrome (67) 的 Python (3.5) 脚本。

Python 安装在 virtualenv 中.

大约 50% 的时间脚本运行没有错误。其他 50% 我得到以下错误。这只是 chrome/chromedriver(两个直接来自 Google 的最新版本)中的一个普通错误,还是可能与我的设置/代码有关?

我的代码非常标准:

options = webdriver.ChromeOptions()                                                                                                                                                                        
options.add_argument('headless')
options.binary_location='/usr/bin/google-chrome-stable'
options.add_argument('window-size={}x{}'.format(*self.window_size))
self.driver = webdriver.Chrome(chrome_options=options)

错误信息:

  File "./grab-regulars.py", line 25, in __init__
self.driver = webdriver.Chrome(chrome_options=options)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 245, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
response = self.command_executor.execute(driver_command, params)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 496, in _request
resp = self._conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.5/socket.py", line 576, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com