selenium安装
pip install selenium一、phantomjs安装
1、Mac环境
phantomjs下载:http://phantomjs.org/download.html
淘宝镜像:https://npm.taobao.org/mirrors/phantomjs
将 phantomjs bin 文件路径加入环境变量:
vim ~/.bash_profile内容
# phantomjs
export PHANTOMJS_PATH=/Users/user/Applications/phantomjs-2.1.1-macosx
export PATH=$PATH:${PHANTOMJS_PATH}/bin执行
source ~/.bash_profile验证
phantomjs --version如果程序报错可是试试加个软连
ln -s /Users/user/Applications/phantomjs-2.1.1-macosx/bin/phantomjs /usr/local/bin/phantomjs2、Linux环境
淘宝镜像: https://npm.taobao.org/mirrors/phantomjs
# 下载
wget https://npm.taobao.org/mirrors/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
# 解压
yum -y install bzip2
tar xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
# 软连
ln -s phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs检查
$ phantomjs --version如果报错
phantomjs: error while loading shared libraries: libfontconfig.so.1:
cannot open shared object file: No such file or directory安装依赖
yum -y install fontconfig-develchromedriver下载:
谷歌下载:https://sites.google.com/a/chromium.org/chromedriver/downloads
淘宝镜像:https://npm.taobao.org/mirrors/chromedriver
复制文件
$ cp chromedriver /usr/local/bin/查看是否成功安装:
phantomjs --version
chromedriver --version参考:
- mac 上安装selenium, phantomjs 和 chromedriver
- centos7下运行phantomjs报phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open
- tar (child): lbzip2: Cannot exec: No such file or directory 解决方法










