• python3删除公司邮件


    #coding:GBK
    '''
    Created on 2017年8月4日

    @author: peiwenxiang
    '''

    import time
    import re
    import os
    from selenium import webdriver
    from selenium.webdriver.support import expected_conditions as EC


    def email():
      while True:
        te = driver.find_element_by_xpath('//*[@id="panel"]/table/tbody/tr[2]/td/div[1]/div[2]/div/div[2]/span/span').text
        num = re.findall('d+', te)
        #通过页数判断需要删除多少次,页数为0就不删除
        if int(num[0]) == 0:
          break

        driver.find_element_by_name('checkall').click()#全选
        time.sleep(1)
        driver.find_element_by_xpath('//*[@id="panel"]/table/tbody/tr[2]/td/div[1]/div[1]/div/a[1]/span').click()#删除
        time.sleep(2)
        

        #判断alert提示是否存在
        result = EC.alert_is_present()(driver)
        if result:
          alert = driver.switch_to_alert()
          alert.accept()
          time.sleep(2)


    options = webdriver.ChromeOptions()
    options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
    driver = webdriver.Chrome(chrome_options=options)
    driver.get('http://mail.vcredit.com/login.jsp')
    driver.maximize_window()
    driver.implicitly_wait(60)

    time.sleep(2)

    uname = driver.find_element_by_name('username')
    uname.send_keys('*****@vcredit.com')

    pword = driver.find_element_by_name('passwd')
    pword.send_keys('******')

    time.sleep(1)

    driver.find_element_by_name('B1').click()

    time.sleep(1)

    #删除收件箱
    driver.find_element_by_xpath('//*[@id="menumailbox"]/li[1]/a').click()

    time.sleep(1)

    email()

    #删除已删除里面的邮件

    driver.find_element_by_xpath('//*[@id="menumailbox"]/li[4]/a').click()
    time.sleep(1)

    email()

    driver.quit()

    #结束相关进程

    ifexistchrome=os.system('tasklist|findstr "chrome.exe"')
    ifexistDr=os.system('tasklist|findstr "chromedriver.exe"')
    if ifexistchrome==0 and ifexistDr==0:
      os.system('taskkill /f /im "chrome.exe"')
      os.system('taskkill /f /im "chromedriver.exe"')
    ifexistcmd=os.system('tasklist|findstr "chrome.exe"')
    if ifexistcmd==0:
      os.system('taskkill /f /im "cmd.exe"')

  • 相关阅读:
    http
    Hive与HBase的区别与联系
    超好用python库(Pathlib)
    JS中every()和some()的用法
    kubectl create 和 kubectl apply区别
    Servlet/Tomcat/ Spring 之间的关系
    Android Fragment详解
    vue路由钩子拦截器beforeEach和afterEach及页面路由变化路由监听
    Vue + Webpack 将路由文件分拆为多个文件分别管理
    VUE中常用的几种import(模块、文件)引入方式
  • 原文地址:https://www.cnblogs.com/sammy1989/p/7285827.html
Copyright © 2020-2023  润新知