def parseHtml(self, item): """ 解析退信内容 获取mobile、batchCode、subBatchCode、templateCode :param item: :return: """ result = { "sendResult": item.get("sendSubject", ""), "mobile": "", "batchCode": "", "subBatchCode": "", "templateCode": "", "email": "" } html_path = item.get("resultHtml", "") """文件是否存在 或后缀名不正确""" if not html_path or html_path.find("html") < 0: return result """读取内容""" file_info = BusinessUtil.read_file(html_path) """判断内容是否为空""" if not file_info: return result """解析数据""" parse_text_result = BusinessUtil.parse_eml_text_param(file_info) """更新""" result.update(parse_text_result) return result
def get_send_email_content(result): """ 获取邮件内容 :param result: :return: """ """获取文件路径""" templatePath = result.get("templatePath") """读取文件内容""" file_content = BusinessUtil.read_file(templatePath) if not file_content: raise Exception("读取文件内容异常") """替换内容参数""" randomNum = ''.join( random.sample([ 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a' ], 10)) result["randomNum"] = randomNum """邮箱加密""" email = result.get("email") secret_email = BusinessUtil.encrypt_aes("adsawdws", email) result["secret_email"] = secret_email file_content = replace_file_content(file_content, result) return file_content
def parseText(self, item): """ 解析退信内容 获取sendResult :param item: :return: """ result = {"sendResult": ""} text_path = item.get("resultText", "") """文件是否存在""" if not text_path: return result """读取文件内容""" text_content = BusinessUtil.read_file(text_path) """解析""" sendResult = BusinessUtil.search_send_result(text_content) """结果不为空""" if sendResult: result["sendResult"] = sendResult[0].strip() return result