ubuntu下安装无界面浏览器
ubuntu下安装PhantomJS
1.下载:
- 32位:wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-i686.tar.bz2
- 64位:wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
2.解压:
- 32 位:tar -xvf phantomjs-2.1.1-linux-i686.tar.bz2
- 64 位:tar -xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
3.移动文件
- sudo mv phantomjs-2.1.1-linux-x86_64.tar.bz2 /usr/local/src/phantomjs
4.安装相关依赖:
- sudo apt-get install build-essential chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 -y
5.设置环境变量:
- sudo ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
6.验证安装
- 在控制台输入 phantomjs -v
ubuntu下安装chrome
1.下载:
-
1 sudo apt-get install libxss1 libappindicator1 libindicator7 2 wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 3 sudo dpkg -i google-chrome*.deb # Might show "errors", fixed by next line 4 sudo apt-get install -f 5 google-chrome --version # 查看版本
2.下载chromedriver:
- https://npm.taobao.org/mirrors/chromedriver
- 选择对应的浏览器版本,下载对应的chromedriver
- 解压,上传到服务器的/usr/bin目录下
3.赋予权限:
- chmod 777 chromedriver
- 赋予权限