Skip to content

Instantly share code, notes, and snippets.

@georgeh
Created January 11, 2017 18:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgeh/334b898081009607ee1e9f59c03d2b6f to your computer and use it in GitHub Desktop.
Save georgeh/334b898081009607ee1e9f59c03d2b6f to your computer and use it in GitHub Desktop.
#!/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