1. 查看chorm的版本号,在chorm的地址栏输入:
chrome://version/
2. 下载对应的chromedriver版本:
http://chromedriver.storage.googleapis.com/index.html
3. mac系统:
a.代码中添加chromdriver文件的路径,如果失败,尝试b方法。
driver = webdriver.Chrome('/Users/rand/Softwore/chromedriver')
b.加入环境变量PATH中:
sudo vi ~/.bash_profile
# 改成chromedriver文件目录的路径
export PATH=../chromedriver:$PATH
source ~/.bash_profile
4. win系统:
a. 将chromdriver文件目录加入环境变量PATH中,如果失败尝试b。
b. 将chromdriver复制到python3.exe文件夹下。
最后弹出界面如下: