mail parser basement
This commit is contained in:
parent
8c7f7ce04c
commit
088edd7280
|
@ -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
|
|
@ -7,6 +7,9 @@ import mailbox
|
||||||
import email.header
|
import email.header
|
||||||
import email.message
|
import email.message
|
||||||
|
|
||||||
|
from parser.Bahn import Bahn
|
||||||
|
|
||||||
|
|
||||||
if 2 != len(sys.argv):
|
if 2 != len(sys.argv):
|
||||||
print("Error. Please povide your mailbox file (mbox) as parameter with the script!")
|
print("Error. Please povide your mailbox file (mbox) as parameter with the script!")
|
||||||
exit()
|
exit()
|
||||||
|
@ -45,5 +48,9 @@ mbox = mailbox.mbox(mboxfile)
|
||||||
for message in mbox:
|
for message in mbox:
|
||||||
mFrom = decode_mime_words(message['from'])
|
mFrom = decode_mime_words(message['from'])
|
||||||
mSubject = decode_mime_words(message['subject'])
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue