import json import feedparser import datetime url = "http://www.google.com/reader/public/atom/user%2F07819160697092147323%2Fstate%2Fcom.google%2Fbroadcast" feed = feedparser.parse( url ) entry = feed['entries'][0] counter = 10 json_object = {} json_object["date"] = datetime.date.today().isoformat() json_object["author"] = "Curtis Lassam" json_object["blurb"] = "" json_object["top10"] = [] for entry in feed['entries']: json_entry = {} if entry.has_key('subtitle'): comment = entry['subtitle'] else: comment = "" comment_br = comment.find("
\n") comment_bq = comment.find("") if comment_br == -1 or comment_bq == -1: comment = "" else: comment = comment[comment_br+7:comment_bq] json_entry['body'] = comment.encode('utf-8') json_entry['title'] = entry['title'].encode('utf-8') json_entry['link'] = entry['link'].encode('utf-8') json_entry['category'] = "Misc" json_object['top10'].append( json_entry ) counter -= 1 if counter == 0: break print json.dumps( json_object, sort_keys=True, indent=4 )