1、验证python环境
在运行页面,输入cmd,点击【确定】

输入python,出现python版本号,证明已安装python

2、查看是否已安装selenium
在cmd窗口输入pip list,如果返回的结果里包含selenium,说明已安装selenium

或者
通过执行pip install selenium,如果日志提示already satisfied,则说明selenium已安装

3、安装浏览器驱动
将浏览器驱动.exe文件放至python安装目录下
这里安装chrome浏览器驱动为例,查看浏览器版本

chrome驱动下载地址:
https://registry.npmmirror.com/binary.html?path=chromedriver/
因为这里的浏览器版本是103,取103开头的任意一个都行

点击进入,根据操作系统选择对应的安装包,由于本地使用的是windows操作系统,所以下载红框的安装包

查看python安装路径,在cmd窗口,执行where python,获取python安装路径

将下载得到的浏览器驱动安装包解压,得到chromedriver.exe,将chromedriver.exe放至python安装路径,从上图可以看出我的python安装路径是D:\python\setup,所以chromedriver.exe就放在这个路径下

网友评论