Skip to content

Instantly share code, notes, and snippets.

@kozmonaut
Created February 11, 2015 14:08
Show Gist options
  • Save kozmonaut/4f33b8330112f6f43377 to your computer and use it in GitHub Desktop.
Save kozmonaut/4f33b8330112f6f43377 to your computer and use it in GitHub Desktop.
Parse RSS feed and store it to file
from urllib import urlopen
from xml.etree.ElementTree import parse
rss_url = urlopen('http://www.dropsql.com/feed')
xml = parse(rss_url)
f = open('dropsql-feeds.txt', 'w')
# Looks for all item elements under channel tag
for item in xml.iterfind('channel/item'):
title = item.findtext('title')
date = item.findtext('pubDate')
link = item.findtext('link')
header = ('%s / %s \n' %(title, date))
f.write(header.encode('utf-8'))
f.write(link + '\n\n')
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment