chromedriver下载与安装方法,亲测可用

chromedriver下载地址:
http://chromedriver.storage.googleapis.com/index.html
http://npm.taobao.org/mirrors/chromedriver/

两个地址都可以下载,根据自己的chrome浏览器的版本选择下载即可
查看浏览器版本 ↓,我的版本为88.0.4324.104,目前最新版


打开,chromedriver下载地址,没有找到88.0.4324.104对应的驱动,下载了88.0.4324.96的


下载解压后

把exe文件复制到浏览器的安装目录下:C:\Program Files (x86)\Google\Chrome\Application
(要根据自己实际安装目录)

把exe文件复制到python的安装目录下:

配置环境变量:此电脑→右击属性→高级系统设置→环境变量→用户变量→Path→编辑→新建,将以下路径复制,然后不要忘记后续全部点击确定

C:\Program Files (x86)\Google\Chrome\Application\

打开pycharm,输入以下代码,测试一下是否驱动成功

from selenium import webdriver

driver = webdriver.Chrome()
url = 'https://www.csdn.net/'
driver.get(url)
driver.maximize_window()

成功!!

注意:浏览器版本自动更新后,可能驱动与之不匹配会报错,如下所示:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 99
Current browser version is 102.0.5005.63 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe

此时我们需要重新下载与浏览器对应的驱动,覆盖如下两个位置

来源:zhoukeguai

物联沃分享整理
物联沃-IOTWORD物联网 » chromedriver下载与安装方法,亲测可用

发表评论