1.python中安装selenium
直接cmd中输入pip install selenium
安装好后可以用pip show selenium来查看安装selenium的版本。
2.将浏览器驱动放入python中
我用的浏览器是谷歌,所以下载谷歌驱动。
先看直接浏览器是什么版本。点击谷歌浏览器的设置–>关于chrome就可以看到版本号
然后在网站http://chromedriver.storage.googleapis.com/index.html中找到对应版本的。因为没有完全对应的,所以我选了最近的107.0.5304.62
解压后会得到的chromedriver.exe
复制到两个位置:
- 复制一份到Python文件夹的scripts路径下 (C:\Users\wushaofang\AppData\Local\Programs\Python\Python39\Scripts)
- 如果用的是pycharm软件,需要复制到路径 C:\Users\wushaofang\AppData\Local\Programs\Python\Python39\Lib\site-packages\selenium\webdriver\chrome。
验证
使用代码进行验证
<