mail parser basement

This commit is contained in:
Rob 2019-07-30 15:52:35 +02:00
parent 8c7f7ce04c
commit 088edd7280
3 changed files with 33 additions and 1 deletions

25
src/Mail/parser/Bahn.py Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
A parser to get events of Bahn.de out of there Emails
'''
'''
A parser to get events of Bahn.de out of there Emails
'''
class Bahn:
'''
@param input must be string with html
@return all events as list
'''
@staticmethod
def getEvents(html):
#hier mit beautifulsoup events rausholen und in liste packen
events = []
return events

View File

View File

@ -7,6 +7,9 @@ import mailbox
import email.header
import email.message
from parser.Bahn import Bahn
if 2 != len(sys.argv):
print("Error. Please povide your mailbox file (mbox) as parameter with the script!")
exit()
@ -45,5 +48,9 @@ mbox = mailbox.mbox(mboxfile)
for message in mbox:
mFrom = decode_mime_words(message['from'])
mSubject = decode_mime_words(message['subject'])
print( getbody(message))
mContent = getbody(message)
if mFrom == 'BahnCard-Service <noreply.bahncard-service@bahn.de>':
events = Bahn.getEvents(mContent)
print(events)