环境 ubuntu16.04 python3
安装selenium
sudo pip3 install seleium
默认安装完是支持firefox,但是更新得太慢对于较新的firefox已经不支持了,需要安装geckodriver,地址 https://github.com/mozilla/geckodriver/releases/
下载完后解压然后在终端中cd到下载文件路径下,下面以路径为下载为例
依次执行以下命令:
安装xvfb
sudo apt-get install xvfb
安装pyvirtualdisplay
sudo pip install pyvirtualdisplay
cd 下载
安装geckodriver
cp geckodriver /usr/bin
二。:chrome的环境配置:
安装chrome,已安装可以跳过
sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get install -f
安装vxfb
sudo apt-get install xvfb
安装chrome driver:
sudo apt-get install unzip
wget -N http://chromedriver.storage.googleapis.com/2.26/chromedriver_linux64.zip (下载不下来可以切换到windows下用迅雷下载,或者在这里下载https://pan.baidu.com/s/1cAbwn0 下载完后cd到下载目录)
unzip chromedriver_linux64.zip
chmod +x chromedriver
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver