最近对于python的第三方库pandas比较有兴趣,在学习的过程中也简单的结合selenium做了一个简单的小工具

  最新公司用一个外部系统来记录,追踪BUG,可是这个系统并不是专业的BUG管理系统,所以对于数据筛选,查看不是很友好。无法满足日常需求,所以就只能自己来倒腾一下了.这里只是实现了很简单的小功能,我需要得出每天关闭BUG的数量 (暂时没有做界面,也没有封装成exe)

主要用的定位方法为xpath,只是用到了很皮毛的程度,这个pandas工具对于数据处理的方面还是比较强大的,后续可以做更多的数据分析方面的练习

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from selenium import webdriver
import datetime,time
import pandas as pd
import os 
path =r""
url=""
dt = datetime.datetime.strptime(datetime.datetime.now().strftime("%Y-%m-%d"), "%Y-%m-%d")
dt=dt.strftime('%Y-%m-%d %H:%M:%S') #获取当前凌晨的时间后,将其转换为'str'
 #判断下载路径下是否存在之前下载的文件,有的话删除
def check_file():
    for root,dirs,files in os.walk(path): 
        for name in files:
            if name.startswith('_itServiceItsuesList_'):
                os.remove(os.path.join(root,name))
                print("Delete File:"+os.path.join(root,name))
            else:
                pass
#登录
def login(url): 
    drvier.get(url)
    time.sleep(1)
    drvier.find_element_by_id('loginid').click()
    time.sleep(1)
    drvier.find_element_by_id('loginid').send_keys("")
    time.sleep(1)
    drvier.find_element_by_id('userpassword').click()
    drvier.find_element_by_id('userpassword').send_keys("")
    time.sleep(1)
    drvier.find_element_by_id('login').submit()
    time.sleep(3)
    return drvier
#去掉指定的位置,按照一定的规则筛选数据,导出excel
def IT():
    driver=login(url)   
    driver.find_element_by_link_text(u'服务台').click()
    driver.find_element_by_link_text(u'待办问题').click()
    fr=driver.find_element_by_xpath('//*[@id="mainframe"]')
    driver.switch_to.frame(fr)
    driver.find_element_by_xpath('//*[@id="shortcut$text"]').click()
    driver.find_element_by_xpath('//*[@id="mini-25$1"]/td[2]').click() #由我创建
    driver.find_element_by_xpath('//*[@id="type"]/span/span/span[2]/span').click() #事件状态
    time.sleep(2)
    driver.find_element_by_xpath('//*[@id="mini-7$ck$14"]').click() #关闭
    #driver.find_element_by_xpath('//*[@id="mini-7$ck$all"]').click() #全选
    driver.find_element_by_xpath('//*[@id="type"]/span/span/span[2]/span').click()
    driver.find_element_by_xpath('//*[@id="a1"]/span').click() #查询
    driver.find_element_by_xpath('//*[@id="queryForm"]/div/table[5]/tbody/tr/td[1]/a[2]/span').click() #导出excel
    time.sleep(3)   #
    driver.find_element_by_xpath('//*[@id="winSearch"]/div/div[2]/div[3]/div/a[1]/span').click() #导出按钮
    time.sleep(8)  #等待下载完成
    driver.close()
def analysics():
    name=[n for n in os.listdir(path) if n.startswith('_itServiceItsuesList_')]  #获取已XX文件命名的文件
    root=os.path.join(path,name)
    df=pd.read_excel(root)
    data=df.shape   # 获取总行与总列数 (行,列)
    data_rows=data[0] #获取总行数
    for row in range(data_rows):
        str_=str((df.loc[row])[72])
        if str_!='nan':
            if str_>dt:
                #print((df.loc[row])[72])
            else:
                pass
        else:
            pass
    print(count)
    return count
def main():
    check_file() 
    drvier=webdriver.Chrome()
    drvier.maximize_window()
    drvier.implicitly_wait(5)  #设置隐性等待时间
    IT()
    analysics()
if __name__=='__main__':
    main()

  

  

练习4-python+selenium+pandas的更多相关文章

  1. Python+Selenium爬取动态加载页面(2)

    注: 上一篇<Python+Selenium爬取动态加载页面(1)>讲了基本地如何获取动态页面的数据,这里再讲一个稍微复杂一点的数据获取全国水雨情网.数据的获取过程跟人手动获取过程类似,所 ...

  2. Python+Selenium爬取动态加载页面(1)

    注: 最近有一小任务,需要收集水质和水雨信息,找了两个网站:国家地表水水质自动监测实时数据发布系统和全国水雨情网.由于这两个网站的数据都是动态加载出来的,所以我用了Selenium来完成我的数据获取. ...

  3. python+selenium 浏览器的问题

    以前用selenium调用firefox是不需要驱动的,最近安装了python3.52+最新的firefox 发现调不起来了 搜索以后发现Firefox 47+需要搞个firefox的驱动 gecko ...

  4. 一次完整的自动化登录测试-基于python+selenium进行cnblog的自动化登录测试

    Web登录测试是很常见的测试!手动测试大家再熟悉不过了,那如何进行自动化登录测试呢!本文作者就用python+selenium结合unittest单元测试框架来进行一次简单但比较完整的cnblog自动 ...

  5. Python + Selenium 实现登录Office 365

    最近捡起之前用的Python + Selenium实现工作中需要的登录Office 365功能.(吐槽:国内网络真是卡,登录Office 365实属不易.另外Selenium这样的网站都要墙,无法理解 ...

  6. python+selenium+Robot

    准备工作: 1.下载python2.7 http://python.org/getit/ 2.下载下载setuptools [python 的基础包工具] 可以帮助我们轻松的下载,构建,安装,升级,卸 ...

  7. python+selenium运行报错UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

    使用python+selenium运行自动化脚本时,打印某一段文字出现UnicodeEncodeError: 'ascii' codec can't encode characters in posi ...

  8. Functional testing - python, selenium and django

    Functional testing  - python selenium django - Source Code : from selenium import webdriverfrom sele ...

  9. python selenium自动化(二)自动化注册流程

    需求:使用python selenium来自动测试一个网站注册的流程. 假设这个网站的注册流程分为三步,需要提供比较多的信息: 在这个流程里面,需要用户填入信息.在下拉菜单中选择.选择单选的radio ...

  10. 使用python selenium进行自动化functional test

    Why Automation Testing 现在似乎大家都一致认同一个项目应该有足够多的测试来保证功能的正常运作,而且这些此处的‘测试’特指自动化测试:并且大多数人会认为如果还有哪个项目依然采用人工 ...

随机推荐

  1. 机器学习-KNN算法详解与实战

    最邻近规则分类(K-Nearest Neighbor)KNN算法 1.综述 1.1 Cover和Hart在1968年提出了最初的邻近算法 1.2 分类(classification)算法 1.3 输入 ...

  2. 如何利用scrapy新建爬虫项目

    抓取豆瓣top250电影数据,并将数据保存为csv.json和存储到monogo数据库中,目标站点:https://movie.douban.com/top250 一.新建项目 打开cmd命令窗口,输 ...

  3. Codeforces Round #427 (Div. 2) - B

    题目链接:http://codeforces.com/contest/835/problem/B 题意:给定一个数k和一个数字串n.问你最少改几个数字才能满足所有数字的和不小于k. 思路:考虑贪心,每 ...

  4. CRMEasy知识库访问权限

    知识库设置BCCBINFO文件夹为共享文件夹,给予普通域用户和管理员域用户完全控制权限,但是当以管理员域用户身份对文件进行操作后,以普通域用户登录不会有效果,甚至出现“访问权限”的错误,这是由于文件夹 ...

  5. Effective C++条款05:了解C++默默编写并调用哪些函数

    class Empty{}; class Empty{ Empty(){}; Empty(const Empty& rhs){}; ~Empty(){}; Empty& operato ...

  6. ssh跳板到其他服务器

    https://my.oschina.net/foreverich/blog/657075 http://mingxinglai.com/cn/2015/07/ssh-proxycommand/ 查看 ...

  7. git如何将本地文件关联到远程服务器

    很多时候,当我们关联git服务器的时候,本地都有可能会有一些开发的东西需要同步上去.那怎么样设置同步呢!跟我来做,简易配置: git本地关联远程项目:      第一步:选择目录           ...

  8. bzoj4165 矩阵 堆维护多路归并

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=4165 题解 大概多路归并是最很重要的知识点了吧,近几年考察也挺多的(虽然都是作为签到题的). ...

  9. SpringBoot整合表单验证注解@Validated,以及分组验证

    首先引入jar包 <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate ...

  10. rocketmq运维管理

    # 运维管理--- ### 1 集群搭建 #### 1.1 单Master模式 这种方式风险较大,一旦Broker重启或者宕机时,会导致整个服务不可用.不建议线上环境使用,可以用于本地测试. #### ...