mac自带python2.7,自己下载了python3.5,pip list查看系统中的安装包,本人电脑中已经安装了pip和setuptools,若未安装,请先使用
- 1
- 1
若使用命令有问题,可自行到官网下载相应安装包,执行python setup.py install 安装即可;
1、安装selenium
执行 python3 -m pip install selenium
2、安装chrome驱动
驱动下载地址:http://docs.seleniumhq.org/download/选择对应系统的浏览器驱动
或者直接到
https://sites.google.com/a/chromium.org/chromedriver/下载最新版mac chrome驱动(需翻墙);
我下载了mac64.zip和linux64.zip,共享地址:
链接: https://pan.baidu.com/s/1nvdKv7F 密码: uc2i
使用uname -a
查看自己的系统是64位还是32位;
3、配置chrome驱动
将解压后的chromedriver移动到/usr/local/bin目录下
否则在运行脚本时,会提示
chromedriver executable needs to be in PATH错误
4、selenium第一个脚本
编写第一个selenium脚本程序:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
运行结果如下:
还有点小激动呢,嘻嘻!