Created
December 12, 2014 00:46
-
-
Save kathawala/0a195915c2008875359d to your computer and use it in GitHub Desktop.
A simple parser for GMail's Atom feed xml. Prints out the Title and Summary and Email address of sender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as etree | |
tree = etree.parse('/home/farhan/bin/email.xml') | |
root = tree.getroot() | |
for entry in root.iter('{http://purl.org/atom/ns#}entry'): | |
for title in entry.findall('{http://purl.org/atom/ns#}title'): | |
print ('TITLE: ', title.text) | |
for author in entry.findall('{http://purl.org/atom/ns#}author'): | |
for email in author.findall('{http://purl.org/atom/ns#}email'): | |
print ('FROM: ', email.text) | |
for summary in entry.findall('{http://purl.org/atom/ns#}summary'): | |
print (summary.text[0:80], '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment