首页 > 代码库 > Installing Selenium and ChromeDriver on Ubuntu
Installing Selenium and ChromeDriver on Ubuntu
I recently got Selenium, Google Chrome, and ChromeDriver installed and working on a DigitalOcean instance running 64-bit Ubuntu 14.04. Here’s how:
First, install Google Chrome for Debian/Ubuntu:
sudo apt-get install libxss1 libappindicator1 libindicator7wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.debsudo dpkg -i google-chrome*.debsudo apt-get install -f
Now, let’s install xvfb
so we can run Chrome headlessly:
sudo apt-get install xvfb
Install ChromeDriver:1
sudo apt-get install unzipwget -N http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zipunzip chromedriver_linux64.zipchmod +x chromedriversudo mv -f chromedriver /usr/local/share/chromedriversudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriversudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
Install some Python dependencies for Selenium:
sudo apt-get install python-pip## (Optional) Create and enter a virtual environment:# sudo apt-get install python-virtualenv# virtualenv env# source env/bin/activatepip install pyvirtualdisplay selenium
Now, we can do stuff like this with Selenium in Python:
from pyvirtualdisplay import Displayfrom selenium import webdriverdisplay = Display(visible=0, size=(800, 600))display.start()driver = webdriver.Chrome()driver.get(‘http://christopher.su‘)print driver.title
Installing Selenium and ChromeDriver on Ubuntu
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。