Created
January 11, 2017 18:22
-
-
Save georgeh/334b898081009607ee1e9f59c03d2b6f to your computer and use it in GitHub Desktop.
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
#!/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