Permalink
Browse files

Notify only that fetching posts not previously fetched.

Ignore all errors (presumably, either temporary and will not occur next time
or user doesn't really care to debug, but does want to continue to next post).
  • Loading branch information...
1 parent 5163013 commit 3b638179df78395c97fa8640c9f1b73f77d7378c @daniel-vainsencher daniel-vainsencher committed Mar 9, 2012
Showing with 13 additions and 10 deletions.
  1. +13 −10 ghettorss-update.py
View
@@ -209,7 +209,6 @@ def fetch_post(cursor, feed_id, entry):
title = entry['title']
else:
title = "(no title)"
- print " Fetching post \"%s\"" % (title)
if "author" in entry:
author = entry['author']
else:
@@ -240,22 +239,26 @@ def fetch_post(cursor, feed_id, entry):
base_url = link_parse[2]
if not fetched:
# fetch the page
- conn = httplib.HTTPConnection(server)
- conn.request("GET", base_url, None, {})
- network_data = None
try:
+ print " Fetching post \"%s\"" % (title)
+ conn = httplib.HTTPConnection(server)
+ conn.request("GET", base_url, None, {})
+ network_data = None
response = conn.getresponse()
if (response.status == 200):
network_data = response.read()
conn.close()
+ if network_data <> None:
+ # parse the page and download supporting files
+ parser = ImgCssParser(cursor, post_id, server, base_url)
+ parser.feed(network_data)
+ page = parser.get_new_page()
+ cursor.execute("UPDATE posts SET fetched=1, data=? WHERE id=?", (page, post_id))
+
except ValueError:
print " **** Caught a ValueError while fetching %s%s" % (server, base_url)
- if network_data <> None:
- # parse the page and download supporting files
- parser = ImgCssParser(cursor, post_id, server, base_url)
- parser.feed(network_data)
- page = parser.get_new_page()
- cursor.execute("UPDATE posts SET fetched=1, data=? WHERE id=?", (page, post_id))
+ except:
+ print " Failed."
def process_feed(original_feed):

0 comments on commit 3b63817

Please sign in to comment.