zoukankan      html  css  js  c++  java
  • 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"')

  • 相关阅读:
    三国演义中的十大谎言 VS 程序员十大口头禅
    Node.js 的单线程事件驱动模型和内置的线程池模型
    为了让医院把医护还给患者,他们用了这个…
    华为云数据库内核专家为您揭秘:GaussDB(for MySQL)并行查询有多快?
    brew
    Python
    Python
    Python
    AtCoder Beginner Contest 215 (个人题解 A~F)
    AcWing 第 13 场周赛  补题记录
  • 原文地址:https://www.cnblogs.com/sammy1989/p/7285827.html
Copyright © 2011-2022 走看看