python - 使用 Chrome v84 时出现“此版本 ChromeDriver 仅支持 Chrome 84 版”
问题描述
我正在尝试使用 Selenium 在 Python 中打开无头 Chrome 浏览器。我正在使用 Chrome v84 并尝试了 Chromedriver v84 和 v83。我在 Mac 上。
import selenium
from selenium import webdriver
path = r"path/to/chromedriver.exe"
op = webdriver.ChromeOptions()
op.add_argument('headless')
driver = webdriver.Chrome(executable_path = path, options=op)
我也试过这个:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
op = webdriver.ChromeOptions()
op.add_argument('headless')
driver = webdriver.Chrome(ChromeDriverManager().install(), options=op)
它返回:
ValueError: There is no such driver by url http://chromedriver.storage.googleapis.com/LATEST_RELEASE_64.0.3282
我还尝试将 Chromedriver 添加到 PATH 并且可以通过 来检查它是否存在echo $PATH
,但它不起作用。
在通过自制软件安装 Chromedriver 之后,我也尝试运行brew cask upgrade chromedriver
,但它只会安装 Chromedriver v83,并且更新命令只会返回“没有可用更新”之类的内容。
我还尝试通过在终端中/usr/local/bin
运行来添加 Chromedriver 的路径。sudo nano /etc/paths
不幸的是,这一次运行时并没有出现echo $PATH
,正如预期的那样,Python 脚本也没有成功运行。
对此的任何帮助将不胜感激。
解决方案
您好,您需要根据网络浏览器版本使用确切的驱动程序 exe。转到您的浏览器->关于部分并检查 chrome 的版本,然后您可以在https://chromedriver.chromium.org/downloads这个链接中下载 driver.exe
(浏览器版本会不时更新,因此您需要更新驱动程序版本)
推荐阅读
- function - Lua - 使用定义的更多参数调用函数
- javascript - 尝试使用 @click="checkedInput" 在 Vuejs 中显示复选框标签时出现问题?
- c++ - C++:函数参数或模板参数
- qutip - 如何在 QuTip 中停止截断量子对象
- python - QWizardPage.completeChanged.emit() 从 LineEdit 窃取焦点
- javascript - 从 mongodb 渲染图像的最简单方法是什么?
- python - 如何获得每个条形图内显示的值的条形图?
- mysql - 如何处理 wordpress woocommerce 商店的故障转移?
- r - 计算数据框中每一列的数字(因子)在每组中出现的次数
- flutter - 仅从顶部给 Flutter Card 一个高程