Chrome 版本较新,找不到相关 driver
来源:12-2 selenium的介绍和安装

慕虎0285045
2024-06-26
老师,你好!由于 Chrome(mac arm64)的版本已经到了 126,因此按照谷歌的说明我只能下载 最近版本的chrome for testing.app。但是放在在视频中与 anaconda/bin 的位置后,是没法 import webdriver,请问应该如何解决呢?
写回答
2回答
-
小布_老师
2024-06-26
另外
import webdriver,请问应该如何解决呢?
你这个情况,是selenium装好了,但是导入出错
正确的使用selenium库,是
from selenium import webdriver
00 -
小布_老师
2024-06-26
将chromedriver放在anaconda/bin目录下,是方便自动寻找路径。
如果无法使用chromedriver,那可能是环境变量设置有问题。
下方是chrome和chromedriver都没有设置环境变量的情况,你可以参考一下
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options # 创建 Options 选项对象 opt = Options() # 指定 Chrome 浏览器的路径 opt.binary_location = r'F:\Chrome\Application\chrome.exe' # 创建 Service 对象 ser = Service() # 指定 ChromeDriver 的路径 ser.executable_path = r'F:\Chrome\chromedriver\chromedriver.exe' # 初始化 WebDriver,使用之前创建的 Options 和 Service 对象 driver = webdriver.Chrome(options=opt, service=ser) # 打开网页 driver.get('http://www.baidu.com') # 关闭浏览器 driver.quit()
00
相似问题