w=10=sh硒鼓

Python Selenuim Crashes

当我 运行 我的代码崩溃时请帮忙,这是在深夜制作的,所以我可能遗漏了一些明显的问题。我没有像我的其他程序那样启动 chrome 驱动程序,而是 运行 实际 chrome。有解决办法吗?

from selenium.webdriver.common.proxy import Proxy, ProxyType
import time

# change 'ip:port' with your proxy's ip and port
proxy_ip_port = '95.217.168.246:8888'

proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = proxy_ip_port
proxy.ssl_proxy = proxy_ip_port

capabilities = webdriver.DesiredCapabilities.CHROME
proxy.add_to_capabilities(capabilities)

# replace 'your_absolute_path' with your chrome binary absolute path
driver = webdriver.Chrome(r'C:\Users\andre\Desktop\Python dsicord bot\chromedriver',
                          desired_capabilities=capabilities)

driver.get('http://whatismyipaddress.com')

time.sleep(8)```






**Error:** 

```DevTools listening on ws://127.0.0.1:57598/devtools/browser/120e371a-b935-4d04-9057-de3f728ce8b0
Traceback (most recent call last):
  File "c:\Users\andre\Desktop\Python dsicord bot\sys.py", line 17, in <module>
    driver = webdriver.Chrome(r'C:\Users\andre\Desktop\Python dsicord bot\chromedriver',
  File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 93
Current browser version is 92.0.4515.159 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe```

这个错误:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created:This version of ChromeDriver only supports Chrome version 93

基本上是你没有兼容版本的浏览器和浏览器驱动程序。

截至 2021 年 8 月 29 日

Latest stable release: ChromeDriver 92.0.4515.107

和Googlechrome浏览器版本为Version 92.0.4515.159 (Official Build) (64-bit)

下载 link 的 chrome 驱动程序,尝试获取 92.0,这应该可以帮助您解决此问题。