zoukankan      html  css  js  c++  java
  • 通过outlook的web邮箱获取指定邮件内容的邮件

    #encoding=utf-8
    from selenium import webdriver
    import time,re

    class GetFiletestFile(object):
    def __init__(self):
    print "init work..."
    self.driver=webdriver.Chrome(executable_path=r"D:GitBasexxxAdaptors3rdToolschromedriver.exe")

    def GetOutlookInfo(self):
    url="https://mail.myoutlook/owa/#path=/mail"
    self.driver.get(url)
    #登录outlook的web邮箱
    username=self.driver.find_element_by_id("username")
    username.send_keys("myname")
    password=self.driver.find_element_by_id("password")
    password.send_keys("mypwd")
    self.driver.find_element_by_xpath("//div[@class='signinbutton']").click()
    time.sleep(3)
    #点击收件箱
    self.driver.switch_to.default_content()
    self.driver.find_element_by_xpath("//span[@id='_ariaId_51.folder']").click()
    time.sleep(2)
    #通过xpath的相对路径方式定位(这里采用了两个//,相对的相对),传入的参数双引号和单引号需要嵌套使用
    contents=self.driver.find_elements_by_xpath("//div[@autoid='_lv_i']//span[contains(@autoid,'_lv_b')]")
    try:
    results=[]
    for content in contents:
    if (u"天擎提测"in content.text or u"Qbuild"in content.text) and "6.3" in content.text:
    #print content.text
    #需要触发标题的点击动作,才能获取到某个标题的邮件内容
    content.click()
    time.sleep(3)
    mailbody=self.driver.find_element_by_xpath("//div[@class='conductorContent']//div[@id='Item.MessagePartBody']/div/div/div")
    #匹配filetest路径
    if u"filetest提测路径" in mailbody.text:
    #print mailbody.text
    pattern=re.compile(r"haha@1192.0.5.8/output/test/.*qbuild",re.I)
    res=pattern.search(mailbody.text)
    if res:
    #print res.group()
    results.append(res.group())
    #将提测结果列表去重返回
    return list(set(results))
    except Exception as e:
    print e
    finally:
    self.driver.quit()
    print "work done"

    if __name__ == '__main__':

    obj=GetFiletestFile()
    print obj.GetOutlookInfo()

  • 相关阅读:
    使用element-ui的table组件时,渲染为html格式
    vue-quill-editor富文本编辑器,添加了汉化样式却汉化不了
    MySQL版本问题导致的SQLException
    MySQL中 ORDER BY 与 LIMIT 的执行顺序
    MySQL 测试数据批量导入
    CentOS 7 安装 Maven
    CentOS 7 安装 Gradle
    CentOS 7 安装 RabbitMQ
    CentOS 7 安装 Tomcat 8.5.43
    CentOS 7 配置网络
  • 原文地址:https://www.cnblogs.com/skyer/p/6728210.html
Copyright © 2011-2022 走看看