zoukankan      html  css  js  c++  java
  • selenium python 安装

    环境为Win64位系统,默认已经安装python2.7到D:Python27,此次使用的浏览器为chrome

    下面是selenium的安装和chromedriver.exe的下载

    1.安装selenium

    Windows下安装selenium

    打开命令行cmd,到目录D:Python27Scripts,输入下面的命令

    pip install selenium

    回车后,你会看到下面的提示

    Downloading/unpacking selenium Downloading selenium-2.38.1.tar.gz (2.5MB): 2.5MB downloaded Running setup.py egg_info for package selenium Installing collected packages: selenium Running setup.py install for selenium Successfully installed selenium Cleaning up...

    2.下载chromedriver.exe

    下载ChromeDriver驱动包(下载地址: http://chromedriver.storage.googleapis.com/index.html?path=2.7/

    找到对应所需的下载,Windows下没有64位的,可用32位

    指定ChromeDriver所在位置,可以通过两种方法指定(我在此使用了第三种方法)
    1)通过配置ChromeDriver.exe位置到path环境变量实现。
    2)通过webdriver.chrome.driver.系统属性实现。实现代码如下:
    System.setProperty("webdriver.chrome.driver", "C:\Documents and Settings\Administrator\Local Settings\Application Data\Google\Chrome\Application\chromedriver.exe")
    3)把下载的chromedriver.exe直接放入D:Python27文件夹下即可使用
     
    打开python,输入

    from selenium import webdriver     #引用

    driver= webdriver.Chrome()           #显式打开浏览器

    driver.get('https://www.baidu.com/')  #跳转到指定页面

     

  • 相关阅读:
    Quartz_理解2
    Quartz_理解1
    Java监控常用工具 .
    DB2函数大全
    cvs上传复制项目
    PLSQL DEVELOPER 使用的一些技巧【转】
    webservice_模拟报文测试
    Myeclipse插件将wsdl生成java客户端代码
    利用 UltraEdit 重新排版 XML 结构数据
    uoj164. 【清华集训2015】V 统计
  • 原文地址:https://www.cnblogs.com/zy900406/p/6089175.html
Copyright © 2011-2022 走看看