You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法通过ChromeDriverManager().install()安装ChromeDriver的问题求助

解决ChromeDriverManager因地区限制无法下载的问题

方案1:手动下载ChromeDriver并指定本地路径

  • 先查看Chrome浏览器版本:打开Chrome,地址栏输入chrome://version/,找到「版本」字段(例如128.0.6613.119)
  • 下载对应大版本的ChromeDriver(无需完全匹配小版本,大版本一致即可),从国内可靠镜像渠道获取
  • 解压后得到chromedriver.exe(Windows)或chromedriver(Mac/Linux),放到项目目录或系统可识别的路径中
  • 修改代码,替换自动下载逻辑,直接指定本地路径:
import selenium.webdriver.chrome.webdriver
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import pyautogui
import random
import numpy as np
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

options = Options()
options.add_experimental_option("detach", True)
# 替换为你的chromedriver本地路径,Windows示例:r"C:\projects\chromedriver.exe",Mac示例:"/Users/xxx/chromedriver"
driver = webdriver.Chrome(service=Service(r"你的chromedriver本地路径"), options=options)
driver.get("https://www.pinterest.com/ideas/")

方案2:给ChromeDriverManager配置代理

如果需要保留自动下载功能,可通过代理绕过地区限制:

import selenium.webdriver.chrome.webdriver
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import pyautogui
import random
import numpy as np
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
# 新增代理相关导入
from webdriver_manager.core.driver_cache import DriverCacheManager
from webdriver_manager.core.proxy import Proxy, ProxyType

options = Options()
options.add_experimental_option("detach", True)

# 配置代理信息
proxy = Proxy(
    proxy_type=ProxyType.HTTP,
    http_proxy="http://你的代理地址:端口",
    https_proxy="https://你的代理地址:端口"
)

# 带代理初始化driver
driver = webdriver.Chrome(
    service=Service(
        ChromeDriverManager(proxy=proxy, cache_manager=DriverCacheManager()).install()
    ),
    options=options
)
driver.get("https://www.pinterest.com/ideas/")

额外提示

  • 你的代码中重复导入了from selenium.webdriver.common.keys import Keys,可删除一行减少冗余
  • 手动下载时务必保证ChromeDriver与Chrome浏览器大版本一致,否则会触发版本不兼容错误

内容的提问来源于stack exchange,提问作者Mahan Tehrani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 04:05:03