Created
April 10, 2015 18:30
-
-
Save Averroes/1d95e76e625655ae1ef3 to your computer and use it in GitHub Desktop.
parsing simple xml data
This file contains hidden or 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 urllib.request import urlopen | |
from xml.etree.ElementTree import parse | |
# Download the RSS feed and parse it | |
u = urlopen('http://planet.python.org/rss20.xml') | |
doc = parse(u) | |
# Extract and output tags of interest | |
for item in doc.iterfind('channel/item'): | |
title = item.findtext('title') | |
date = item.findtext('pubDate') | |
link = item.findtext('link') | |
print(title) | |
print(date) | |
print(link) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment