1.安装Python (download Python exe file and install it, add path into home)
2.安装Selenium
https://www.cnblogs.com/xiaxiaoxu/p/8909622.html
Option1: pip install selenium (in cmd), 网络环境不好的时候会失败
此时有种解决方案,是将TIMEOUT设为100
pip --default-timeout=100 install selenium

Option2: 下载selenium安装包手动安装 ,下载地址:https://pypi.org/project/selenium/, 选择扩展名为gz的源码包进行下载. 下载后解压,cmd环境进入到setup.py文件所在目录,运行 python setup.py install命令进行安装.
安装完后用pip list可看到selenium的信息,此时就可以用import selenium引入selenium包了.
3.浏览器驱动
chrome
http://npm.taobao.org/mirrors/chromedriver/
找到对应Chrome版本的驱动后,放在一个文件夹下,比如d:/drivers,再将改路径加入到环境变量中即可。
自此,就可以成功运行以下代码了

网友评论