Skip to content

Instantly share code, notes, and snippets.

@nberserk
Created August 31, 2017 12:29
Show Gist options
  • Save nberserk/133ebfabf8a58398de837cb04059000c to your computer and use it in GitHub Desktop.
Save nberserk/133ebfabf8a58398de837cb04059000c to your computer and use it in GitHub Desktop.
parse blogger xml with python
from xml.etree import ElementTree
prefix = '{http://www.w3.org/2005/Atom}'
tree = ElementTree.parse('/blog-08-22-2017.xml')
root = tree.getroot()
def real_tag(tag):
return prefix+tag
for child in root.findall(real_tag('entry')):
category = child.find(real_tag('category'))
if 'post' in category.get('term'):
print child.find(real_tag('title')).text
print child.find(real_tag('published')).text
print child.find(real_tag('content')).text
print ' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment