Exemplo n.º 1
0
    def parseEML(self, item):
        """
		解析eml后缀文件 获取mobile、batchCode、subBatchCode、templateCode
		:param item:
		:return:
		"""
        result = {
            "mobile": "",
            "batchCode": "",
            "subBatchCode": "",
            "templateCode": "",
            "email": ""
        }
        eml_path = item.get("resultAttach", "")
        """文件是否存在 或后缀名不正确"""
        if not eml_path or eml_path.find("eml") < 0:
            return result
        """解析邮件内容"""
        parse_eml_result = BusinessUtil.parse_eml(eml_path)
        """获取发送账号"""
        result.update({"email": parse_eml_result.get("To")})
        """获取文件内容"""
        parse_content = parse_eml_result.get("content")
        """解析数据"""
        parse_text_result = BusinessUtil.parse_eml_text_param(parse_content)
        """更新"""
        result.update(parse_text_result)
        return result
Exemplo n.º 2
0
    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