Created
January 29, 2012 09:26
-
-
Save troyscott/1698010 to your computer and use it in GitHub Desktop.
Convert a rss feed to a python dictionary
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 import ElementTree | |
# For example create doc using ElmentTree | |
# ElementTree.fromstring(xml) | |
def rss_to__dict(doc): | |
# Create a Dictionary to store the data | |
# from the rss feed (xml) | |
rss = {"rss":[]} | |
for feed in doc.findall("channel/item"): | |
# Create a Dictionary for the current item | |
item = {} | |
for items in feed: | |
item[items.tag] = items.text | |
rss["rss"].append(item) | |
return rss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment