Created
February 11, 2015 14:08
-
-
Save kozmonaut/4f33b8330112f6f43377 to your computer and use it in GitHub Desktop.
Parse RSS feed and store it to file
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 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