From 8ae4ec88909c11100fa54d30a5cfc5a68ce47168 Mon Sep 17 00:00:00 2001 From: Nelson Elhage Date: Tue, 9 Feb 2010 17:23:57 -0500 Subject: [PATCH] import-feeds: Handle blogs without tags. --- import-feeds.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/import-feeds.py b/import-feeds.py index 9d4f9bb..5574167 100755 --- a/import-feeds.py +++ b/import-feeds.py @@ -1,6 +1,7 @@ #!/usr/bin/python from lxml import html import yaml +import sys import urllib2 import urlparse @@ -18,7 +19,11 @@ def fetch_links(url): 'comments' not in l.attrib.get('title','')] if candidates: return candidates[0].attrib['href'] - return links[0].attrib['href'] + elif links: + return links[0].attrib['href'] + else: + print >>sys.stderr, "No link found for %s" % (url,) + return None for (name, u) in users.items(): for e in u['links']: @@ -27,9 +32,10 @@ for (name, u) in users.items(): if len(e) == 3: continue link = fetch_links(url) - if not link.startswith('http:'): - link = urlparse.urljoin(url, link) - e.append(link) + if link: + if not link.startswith('http:'): + link = urlparse.urljoin(url, link) + e.append(link) with open('bloggers.yml', 'w') as f: yaml.safe_dump(users, f) -- 2.39.5