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/')  #跳转到指定页面

     

  • 相关阅读:
    java中的迭代器的含义
    angular-指令总结
    angular-ng-model
    angular-创建自定义的指令
    angular-$scope和$rootScope
    angular-过滤器
    Git-pull进入vim窗口解决办法
    Math常用方法
    全局变量和window属性上定义的变量
    透明点点的轮播图
  • 原文地址:https://www.cnblogs.com/zy900406/p/6089175.html
Copyright © 2011-2022 走看看