受企业限制无法升级Chrome至138,如何用Chrome137运行Selenium脚本?
解决Chrome v137环境下运行undetected_chromedriver的问题
方法一:手动指定匹配Chrome 137的ChromeDriver
- 下载与本地Chrome版本(137.0.7151.69)完全匹配的ChromeDriver,注意对应你的操作系统(Windows/macOS/Linux)。
- 修改代码,指定ChromeDriver的路径和对应主版本:
from selenium import webdriver import undetected_chromedriver as uc import time from selenium.webdriver.common.by import By import urllib chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--disable-extensions") # 替换为你下载的ChromeDriver实际路径,指定主版本137 web = uc.Chrome( options=chrome_options, driver_executable_path="/本地路径/chromedriver.exe", version_main=137 ) web.get('https://www....')
方法二:强制undetected_chromedriver适配Chrome 137
如果不想手动下载驱动,可直接通过参数指定版本,让工具自动匹配对应驱动:
from selenium import webdriver import undetected_chromedriver as uc import time from selenium.webdriver.common.by import By import urllib chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--disable-extensions") # 仅指定主版本137,工具会自动拉取匹配的ChromeDriver web = uc.Chrome( options=chrome_options, version_main=137 ) web.get('https://www....')
关键注意事项
- 务必保证ChromeDriver与本地Chrome的完整版本号完全对应,否则仍会触发版本不兼容错误。
- 企业网络受限的情况下,手动下载ChromeDriver的方式更可靠,避免工具自动拉取失败。
内容的提问来源于stack exchange,提问作者Ron2020
相关产品推荐
相关产品推荐

