CentOS  安装 chrome

CentOS 6.5 安装chrome浏览器

vim /etc/yum.repos.d/CentOS-Base.repo

yum  update              // 更新源,使其生效

根据系统版本,在最末尾增加一个节点,如下:

32-bit

[google]
name=Google - i386
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

 

64-bit

[google64]
name=Google - x86_64
baseurl=http://dl.google.com/linux/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

 

安装稳定版本: yum install google-chrome-stable
安装测试版本: yum install google-chrome-beta   (推荐,安装成功

参考推荐: Ubuntu常用软件安装

 

chromedriver 下载配置

chromedriver 官方下载: 

http://chromedriver.storage.googleapis.com/index.html 

chromedriver 配置:

1. 解压 chromedriver_linux32.zip

unzip  chromedriver_linux32.zip

2. 拷贝到 /usr/bin/ 目录下

cp  chromedriver  /usr/bin/

 

Python + Selenium2 + Chrome 爬取网页

For Linux

  1. Check you have installed latest version of chrome brwoser-> chromium-browser -version
  2. If not, install latest version of chrome sudo apt-get install chromium-browser
  3. get appropriate version of chrome driver from here
  4. Unzip the chromedriver.zip
  5. Move the file to /usr/bin directory sudo mv chromedriver /usr/bin
  6. Goto /usr/bin directory and you would need to run something like chmod a+x chromedriver to mark it executable.
  7. finally you can execute the code.

    import os
    from selenium import webdriver
    from pyvirtualdisplay import Display
    
    display = Display(visible=0, size=(800, 600))
    display.start()
    driver = webdriver.Chrome()
    driver.get("http://www.google.com")
    print driver.page_source.encode('utf-8')
    driver.quit()
    display.stop()

 

参考推荐:

Ubuntu常用软件安装

Python+Selenium2 搭建自动化测试环境

Running webdriver chrome with Selenium

使用selenium自动登录淘宝并获取cookie