selenium模块的安装参考前面的一篇文章有关安装模块
今天主要讨论chromedriver的配置
首先下载:
chromedriver的版本一定要与Chrome的版本一致,不然就不起作用。
有两个下载地址:
1、http://chromedriver.storage.googleapis.com/index.html
2、https://npm.taobao.org/mirrors/chromedriver/
当然,你首先需要查看你的Chrome版本,在浏览器中输入chrome://version/
下载对应版本的chromedriver
配置
因为我的环境是anaconda+pychram,所以我下载之后直接把chromedriver.exe放到anaconda的scripts中即可。如下图:
测试代码:from selenium import webdriverimport timedef main(): b = webdriver.Chrome() b.get('https://www.baidu.com') time.sleep(5) b.quit()if __name__ == '__main__': main()
成功配置。
参考文献:https://www.cnblogs.com/lfri/p/10542797.html