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 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

Now, let’s install xvfb so we can run Chrome headlessly:

sudo apt-get install xvfb

Install ChromeDriver:1

sudo apt-get install unzip

wget -N http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
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

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/activate pip install pyvirtualdisplay selenium

Now, we can do stuff like this with Selenium in Python:

from pyvirtualdisplay import Display
from selenium import webdriver display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.Chrome()
driver.get('http://christopher.su')
print driver.title

Footnotes

1: You can find all the ChromeDriver releases here. If you’re using a 32-bit system or a non-Linux OS, the ChromeDriver download used above won’t work.

最新文章

  1. 架构师养成记--14.重入锁ReentrantLock 和 读写锁 ReentrantReadWriteLock
  2. 手机端页面自适应之rem布局
  3. SqlServer批量刷数据执行事务回滚语句备份
  4. ASP.NET MVC的Web Api的实练
  5. 2015年9月10-11日,杨学明老师《IPD DRY RUN》专题培训在武汉某上市企业成功举办!
  6. COMMIT WORK AND WAIT 是在WAIT什么
  7. HDR Defered Shading (using MRT)
  8. linq 和 , 并 , 差 ,交
  9. opengl打开本地bmp图片绘制
  10. [BZOJ 1907] 树的路径覆盖 【树形DP】
  11. 趣味理解ADO.NET对象模型
  12. delphi笔记之nativeXml 转
  13. grunt getHTML
  14. 数组的创建和各种API
  15. 各种电子面单Api接口免费对接-快宝开放平台
  16. Maven 核心原理
  17. lock了mutex的线程退出了却没有unlock时会怎么样?
  18. 虽然不抱希望但也愿.Net和Java之争暂得平息
  19. fibos开发踩坑集合
  20. 20155306 2016-2017-2 《Java程序设计》第九周学习总结

热门文章

  1. Wpf usercontrol dispose
  2. Oracle数据库基础知识
  3. JDBC判断数据库是否插入成功
  4. 利用django创建一个投票网站(二)
  5. bootstrap在jsp中的应用
  6. Nodejs事件引擎libuv源码剖析之:高效队列(queue)的实现
  7. 各种主流浏览器CSS、BUG兼容
  8. Python
  9. C# 开源框架
  10. iPhone屏幕尺寸/launch尺寸/icon尺寸