Created
August 31, 2017 12:29
-
-
Save nberserk/133ebfabf8a58398de837cb04059000c to your computer and use it in GitHub Desktop.
parse blogger xml with python
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
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