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

Instagram爬虫初始化ChromeDriver报错:TypeError不识别executable_path参数

解决Instagram爬虫的两个问题:executable_path报错与Chrome 116驱动匹配

1. 修复__init__() got an unexpected keyword argument 'executable_path'报错

Selenium 4.x 版本起已经移除了executable_path这个直接传参的方式,必须通过Service类来指定驱动文件路径。修改代码如下:

  • 先导入Service类:
    from selenium.webdriver.chrome.service import Service
    
  • 用Service包装驱动路径,再传给Chrome实例:
    service = Service(executable_path="你的chromedriver文件路径")
    driver = webdriver.Chrome(service=service)
    

2. 获取Chrome 116.0.5845.97对应的驱动程序

Chrome从116版本开始,chromedriver不再单独在原驱动页面发布,而是整合到Chrome官方的测试资源体系中,有两种可行方案:

方案一:用第三方库自动管理(推荐)

安装webdriver-manager库,它会自动检测你的Chrome版本,下载并匹配对应的驱动,无需手动查找:

  • 安装命令:
    pip install webdriver-manager
    
  • 修改代码实现自动配置:
    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    from webdriver_manager.chrome import ChromeDriverManager
    
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
    
    这段代码会自动完成驱动的下载、路径配置和浏览器启动,彻底避开版本匹配问题。

方案二:手动下载驱动

如果你偏好手动操作,直接找到Chrome官方提供的对应版本测试驱动,下载后放到本地路径,再用上面的Service方式调用即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 01:38:16