selenium是一个web测试应用框架也可以拿来做爬虫。

1.安装selenium模块

  pip install -U selenium

2.安装selenium模块后需要有相应的浏览器驱动

  A.使用phantomjs

    phantomjs是无界面的测试浏览器

    我用的是phantomjs-2.1.0-linux-x86_64只要直接使用phantomjs-2.1.0-linux-x86_64文件夹里面的额phantonjs就可以了

   from selenium import webdriver

   driver = webdriver.PhantomJS('/home/xx/xx/phantomjs-2.1.0-linux-x86_64/bin/phantomjs')##里面是phantomjs的地址
  driver.get("http://www.baidu.com")

  这样就可以直接使用driver操作无界面的浏览器了

  phantomjs下载地址:

  B.有见面的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
  sudo apt-get install xvfb
  sudo apt-get install unzip
  wget -N http://chromedriver.storage.googleapis.com/2.26/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
  安装相关selenimu
  sudo apt-get install python-pip
  pip install pyvirtualdisplay selenium

  测试代码

 from pyvirtualdisplay import Display
from selenium import webdriver driver = webdriver.Chrome()
driver.get('https://www.baidu.com/')
print driver.title

  相关链接:https://christopher.su/2015/selenium-chromedriver-ubuntu/

  版本对应信息: https://sites.google.com/a/chromium.org/chromedriver/downloads

python selenium 开发环境配置的更多相关文章

  1. python+selenium的环境配置

    以前写过关于python和selenium加myeclipse的环境配置,但是myeclipse启动时过于费时,虽然myeclipse有很好的提示功能,但是作为初学者,我还是直接用python的idl ...

  2. Python selenium chrome 环境配置

    Python selenium chrome 环境配置 一.参考文章: 1. 记录一下python easy_install和pip安装地址和方法 http://heipark.iteye.com/b ...

  3. python语言开发环境配置

    原作者:龙行天下-super 地址:https://www.cnblogs.com/longxingtianxia/p/10181901.html 要点:IDLE是一个轻量级python语言开发环境, ...

  4. Mac python3.5 + Selenium 开发环境配置

    一. python 3.5 1. 下载 2. Mac默认为2.7,所以这里主要介绍如何将系统Python默认修改为3.5. 原理: 1)Mac自带的python环境在: python2.7: /Sys ...

  5. python的开发环境配置-Eclipse-PyDev插件安装

    安装PyDev插件的两种安装方法: 1.百度搜索PyDev 2.4.0.zip,下载后解压,得到Plugins和Feature文件夹,复制两文件夹到Eclipse目录,覆盖即可. 插件的版本要对应py ...

  6. pycharm+PyQt5+python最新开发环境配置

    Python 3.6https://www.python.org/downloads/windows/========================================PyQt5 pip ...

  7. 【Python selenium自动化环境配置】4步搞定ChromeDriver版本选择

    很多刚做自动化的小伙伴,会在ChromeDriver版本选择时犯难,看来大家都被坑过,真正掌握独门绝技,都不是难事儿. 看好了主要步骤就4部 1.确定谷歌浏览器版本 2.找到谷歌浏览器版本与Chrom ...

  8. PyQt5+python+pycharm开发环境配置

    Qt Designer的安装方法 使用Qt Designer可以使用GUI的方式快速生成PyQt代码,本文介绍Qt Designer的安装以及在PyCharm中的配置方法. pip install P ...

  9. pycharm+PyQt5+python最新开发环境配置,踩坑过程详解

    安装工具:Pycharm 专业版2017.3PyQT5python3 pyqt5-tools 设置扩展工具的参数找到setting->tools->external tools,点击加号新 ...

随机推荐

  1. UVA-10917 Walk Through the Forest (dijkstra+DP)

    题目大意:n个点,m条边的无向图.一个人从起点到终点按照下面的走法:从A走向B当A到终点的最小距离比B到终点的最小距离大时.问从起点到终点有多少路径方案. 题目分析:先用dijkstra预处理出终点到 ...

  2. POJ2104 (平方分割)二分查找理解。

    题意:任意区间求第k大数 思路: 预处理:利用平方分割(分桶法)把区间切割成B = sqrt(n)大小的一块块,然后每个各自排序. 二分第k大数x,接着就需要求[l,r]区间中x的排名,与k比较,将两 ...

  3. C++复习4.函数设计基础

    C/C++ 函数设计基础 20130918 函数式程序的基本功能单元,是模块化程序设计的基础,即使函数的功能正确是不够的,因为函数设计的细微缺点很容易导致函数被错用. 了解函数的基本知识,堆栈和堆的相 ...

  4. LeetCode OJ:Palindrome Partitioning(回文排列)

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  5. iOS笔记杂记

    Google Mobile Ads SDK更新至7.2.1不能编译,添加依赖库QuartzCore.framework后正常编译 imageName会把image缓存到手机内存里,不适合大量图片浏览会 ...

  6. ThinkPHP5.0完全开发手册.【CHM】下载

    ThinkPHP5已经出来很长时间了,官网也没有提供CHM格式的手册下载只有PDF格式的,我根据官网的在线手册制作了一个离线版的ThinkPHP5.0完全开发手册.CHM格式的文档.

  7. python编程(最简单的rpc代码)

    [ 声明:版权所有,欢迎转载,请勿用于商业用途. 联系信箱:feixiaoxing @163.com] 采用twisted可以编写最简单的rpc代码. server端代码如下, from twiste ...

  8. CentOS常用命令汇总

    将新创建的数据分配某个用户访问 grant all privileges on zhouzdb.* to 'zhouz'@'%' identified by '1234'; flush privile ...

  9. Windbg 调试工具32位/64位版本下载

    最新的Windbg调试工具32位/64位版本越来越不好下载了,这里通过CSDN的渠道给大家一个下载地址,帮助大家更好下载工具: https://github.com/EasyDarwin/Tools/ ...

  10. 人生苦短之我用Python篇(队列、生产者和消费者模型)

    队列: queue.Queue(maxsize=0) #先入先出 queue.LifoQueue(maxsize=0) #last in fisrt out  queue.PriorityQueue( ...