Parse mailto urls in Python -



Parse mailto urls in Python -

i'm trying parse mailto urls nice object or dictionary includes subject, body, etc. can't seem find library or class achieves this- know of any?

mailto:me@mail.com?subject=mysubject&body=mybody

seems might want write own function this.

edit: here sample function (written python noob).

edit 2, cleanup feedback:

from urllib import unquote test_mailto = 'mailto:me@mail.com?subject=mysubject&body=mybody' def parse_mailto(mailto): result = dict() colon_split = mailto.split(':',1) quest_split = colon_split[1].split('?',1) result['email'] = quest_split[0] pair in quest_split[1].split('&'): name = unquote(pair.split('=')[0]) value = unquote(pair.split('=')[1]) result[name] = value homecoming result print parse_mailto(test_mailto)

python mailto url-parsing

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -