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

时间: 2024-08-04 07:01:19

Installing Selenium and ChromeDriver on Ubuntu的相关文章

selenium chrome chromedriver

转自:http://blog.csdn.NET/huilan_same/article/details/51896672 再使用selenium打开chrome浏览器的时候,需要用chromedriver,而chromedriver与chrome的版本也是要相互适宜的,对应关系如下: chromedriver版本 支持的Chrome版本 v2.24 v52-54 v2.23 v51-53 v2.22 v49-52 v2.21 v46-50 v2.20 v43-48 v2.19 v43-47 v2

selenium使用ChromeDriver

什么是ChromeDriver? ChromeDriver是Chromium team开发维护的,它是实现WebDriver有线协议的一个单独的服务.ChromeDriver通过chrome的自动代理框架控制浏览器,ChromeDriver只与12.0.712.0以上版本的chrome浏览器兼容. 那么要想selenium成功的操作chrome浏览器需要经历如下步骤: 1.下载ChromeDriver驱动包(下载地址:http://chromedriver.storage.googleapis.

selenium与chromedriver的操作

第一次尝试通过webdriver操作chrome 在网上找了些文章了解怎么配置 首先是下载chromedriver,下载地址:http://chromedriver.storage.googleapis.com/index.html 我走了挺多弯路 chromedriver版本都有对应的chrome版本 刚开始我没有考虑到这一点 对应版本如下: chromedriver版本 支持的Chrome版本 v2.32 v59-61 v2.31 v58-60 v2.30 v58-60 v2.29 v56-

Mac 安装Selenium中ChromeDriver步骤

1. 运行代码(Bili 爬虫 16 selenium 抓取淘宝美食信息),报错 from selenium import webdriver browser= webdriver.Chrome() Error信息: 2018/4/15 下午11:52 Error running 'spider': @NotNull method com/intellij/execution/configurations/GeneralCommandLine.getExePath must not return

安装selenium和chromedriver

网上找的算法,在运行爬虫代码时,需要Selenium+Phantomjs实现,我改成了用Selenium+Chrome:针对指定网址,自动打开浏览器,输入关键词搜索,并保存搜索的内容. 1. 安装selenium 安装命令: #安装selenium pip install selenium #查看是否安装成功 pip show selenium 安装如图: 网上有的教程用:pip install -U selenium安装,其中的-U代表升级指定包 #升级指定的包 pip install -U

在Centos7上安装Python+Selenium+Chrome+Chromedriver

1.下载Chrome 上一篇文章已经演示过了Python+Selenium+Firefox+Geckodriver安装步骤并通过自动化脚本打开百度 因此当前只需要安装Chrome和Chromedriver即可 官网下载地址:https://www.google.cn/chrome/(可以通过centos7自带火狐浏览器进行下载RPM包) 百度云下载:https://pan.baidu.com/s/1XLpKO-pIzxc0uw3h2u4YnQ(密码:0vu2) 百度云下载后通过Xftp软件传到C

selenium缺少chromedriver解决方法

1.安装好selenium,运行一段测试代码: from selenium import webdriver brower = webdriver.Chrome() brower.get('www.baidu.com') brower.quit() 如果浏览器没有调起来,并提示以下错误:selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. 按字面

Installing teamviewer 9 on 64-bit Ubuntu 13.10 (转载)

While trying to install Teamviewer 9 on 64-bit Ubuntu 13.10, you’ll get a dependencies error such as this: Unpacking teamviewer (from teamviewer_linux_x64.deb) ... dpkg: dependency problems prevent configuration of teamviewer:  teamviewer depends on

selenium中chromedriver与chrome版本映射关系表 -《狗嗨默示录》-

chromedriver版本 支持的Chrome版本 v2.31 v58-60 v2.30 v58-60 v2.29 v56-58 v2.28 v55-57 v2.27 v54-56 v2.26 v53-55 v2.25 v53-55 v2.24 v52-54 v2.23 v51-53 v2.22 v49-52 v2.21 v46-50 v2.20 v43-48 v2.19 v43-47 v2.18 v43-46 v2.17 v42-43 v2.13 v42-45 v2.15 v40-43 v2