import email
import base64
def decode_mime(_msg, _result=[]):
def _decode(msg, result):
if msg.is_multipart():
for item in msg.get_payload():
_decode(item, result)
else:
if 'content-type' in msg:
_content_type = msg['content-type']
if 'text/html' in _content_type:
decoded_text = base64.decodestring(msg.get_payload())
result.append(decoded_text)
_decode(_msg, _result)
decode_mime(email.message_from_string(_message), result=[])
댓글 없음:
댓글 쓰기