Skip to content

Instantly share code, notes, and snippets.

@georgeh

georgeh/rssgopher.py

Created Jan 11, 2017
Embed
What would you like to do?
#!/usr/local/Python-2.4/bin/python
import feedparser, html2text, os, sys
from textwrap import fill
feed = feedparser.parse("http://george.hotelling.net/index.xml")
filepath = "~/public_html/gopher"
i = 0
for entry in feed['entries']:
i = i + 1
text = html2text.html2text(entry['description'])
filename = "%s/%02d-%s.txt" % (filepath, i, entry['title'])
try:
f = open(filename, "w")
f.write(text)
f.close()
except:
os.unlink(filename)
sys.stderr.write("Could not write file %s" % (filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment