jupyter notebook在使用webdriver时报错,大家能帮忙分析一下原因吗

讨论数量: 1

这个问题是说,找不到驱动 chrome 的 webdriver,可以进行下面几点操作:

  1. 更新 selenium
  2. 对应好 webdriver 和浏览器的版本
  3. 代码中指定webdriver路径 或者 如果你使用的 windows 系统,在我前几年使用 selenium 的时候,可以通过配置 webdriver 的环境变量解决问题

关于代码指定:

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

gecko_driver_path = 'C:\All\software\Anaconda\geckodriver.exe'

service = Service(executable_path=gecko_driver_path)
driver = webdriver.chrome(service=service)
# 打开网页
driver.get("https://www.baidu.com")

这是很久之前我的经验,现在几乎不做爬虫了,希望能帮到您。

4个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!