8 with open('bloggers.yml') as f:
9 users = yaml.safe_load(f.read())
12 tree = html.fromstring(urllib2.urlopen(url).read())
14 '//link[@rel="alternate"][contains(@type, "rss") or ' +
15 'contains(@type, "atom") or contains(@type, "rdf")]')
16 candidates = [l for l in links if
17 'atom' in l.attrib['type'] and
18 'comments' not in l.attrib['href'].lower() and
19 'comments' not in l.attrib.get('title','')]
21 return candidates[0].attrib['href']
23 return links[0].attrib['href']
25 print >>sys.stderr, "No link found for %s" % (url,)
28 for (name, u) in users.items():
34 link = fetch_links(url)
36 if not link.startswith('http:'):
37 link = urlparse.urljoin(url, link)
40 with open('bloggers.yml', 'w') as f:
41 yaml.safe_dump(users, f)