使用selenium实现爬虫程序,需要对应浏览器的驱动。以chrome浏览器为例。无驱动运行程序,会返回错误:
selenium.common.exceptions.WebDriverException: Message: 'chromedriver
1、win系统安装Chrome驱动
1、查看本机Chrome浏览器版本
查看路径:chrome://version/
2、下载对应驱动
下载路径:http://chromedriver.storage.googleapis.com/index.html
3、解压后将chromedriver.exe文件放在两个目录下
一个目录是谷歌浏览器路径(我的是:C:\Program Files (x86)\Google\Chrome\Application)
另一个是python安装路径(我的是:E:\python38)
2、mac系统安装Chrome驱动
1、查看本机Chrome浏览器版本
查看路径:chrome://version/
2、下载对应驱动
下载路径:http://chromedriver.storage.googleapis.com/index.html
3、解压后将chromedriver.exe文件放在两个目录下
一个目录是/usr/local/bin
另一个是python安装路径
执行完以上三步,即可开开心心敲代码了。
网友评论