import smtplib
import pandas as pd
# smtplib这个模块是管发邮件
from email.mime.text import MIMEText
# 构造邮件内容
from email.mime.multipart import MIMEMultipart
import re
import os
from bs4 import BeautifulSoup as bs
#获取测试报告中的结果
def get_result(files):
listRes = []
for i in range(len(files)):
htmls = open(files[i],'r',encoding="utf-8")
htmlcontent = htmls.read()
htmlcontent1 = bs(htmlcontent,'html.parser')
ts = htmlcontent1.table
strs = str(ts)
h = re.findall(r'<td colspan="2">(.*?)</td?', strs)
h1 = h[2]
h11 = h1.replace('(','').replace(')','').replace('/',' ').split(' ')
listRes.append(h11)
return listRes
#邮件内容中写入表格
def get_table(files):
content = get_result(files)
# 构建了一个能发附件的邮件对象
newdata = {'total': {'运营': content[0][0], 'M站': content[1][0], 'APP': content[2][0]},
'success': {'运营': content[0][1], 'M站': content[1][1], 'APP': content[2][1]},
'fail': {'运营': content[0][2], 'M站': content[1][2], 'APP': content[2][2]},
'err