@
NonClockworkChen 115 开始,官方版本在这里
https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json ,手动下载和 Chrome 一致的版本,或者安装 pip install webdriver_manager 4.0 后可以通过下面脚本自动和 Chrome 版本保持一致
import os
import sys
from webdriver_manager.core.utils import read_version_from_cmd
from webdriver_manager.core.os_manager import PATTERN
from webdriver_manager.chrome import ChromeDriverManager
if sys.platform == 'linux':
chrome_path = '/usr/bin/google-chrome'
elif sys.platform == 'darwin':
chrome_path = '/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome'
ver = read_version_from_cmd(f'"{chrome_path}" --version', PATTERN['google-chrome']).split('.')[0]
if sys.platform == 'linux':
driver_path = f'{os.environ["HOME"]}/.wdm/drivers/chromedriver/linux64/{ver}/chromedriver-linux64/chromedriver'
elif sys.platform == 'darwin':
driver_path = f'{os.environ["HOME"]}/.wdm/drivers/chromedriver/mac64/{ver}/chromedriver-mac-x64/chromedriver'
if not os.path.exists(driver_path):
ChromeDriverManager(ver).install()