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

首次使用Selenium运行Chrome WebDriver遇AttributeError问题求助

解决Selenium中AttributeError: 'str' object has no attribute '_ignore_local_proxy'错误

这个错误是因为Selenium 4.x版本不再支持直接将驱动路径字符串传入webdriver.Chrome(),需要通过Service类来管理驱动路径。以下是两种解决方法:

方法一:使用Service类指定驱动路径

修改代码,导入Service类并传入驱动路径:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

driver_path = '/Users/krishpatil/Downloads/chromedriver_mac_arm64/chromedriver'
service = Service(driver_path)
driver = webdriver.Chrome(service=service)
driver.get('https://hoopshype.com/salaries/players/')

方法二:利用Selenium内置的驱动自动管理(推荐)

如果你的Selenium版本是4.6.0及以上,无需手动下载ChromeDriver,Selenium会自动适配并管理驱动:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://hoopshype.com/salaries/players/')

补充验证

  • 若使用方法一,需确保Chrome浏览器版本与ChromeDriver版本完全匹配
  • 执行代码前关闭所有Chrome窗口,避免驱动进程冲突

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 09:29:56