7 with open('bloggers.yml') as f:
8 users = yaml.safe_load(f.read())
11 tree = html.fromstring(urllib2.urlopen(url).read())
13 '//link[@rel="alternate"][contains(@type, "rss") or ' +
14 'contains(@type, "atom") or contains(@type, "rdf")]')
15 candidates = [l for l in links if
16 'atom' in l.attrib['type'] and
17 'comments' not in l.attrib['href'].lower() and
18 'comments' not in l.attrib.get('title','')]
20 return candidates[0].attrib['href']
21 return links[0].attrib['href']
23 for (name, u) in users.items():
29 link = fetch_links(url)
30 if not link.startswith('http:'):
31 link = urlparse.urljoin(url, link)
34 with open('bloggers.yml', 'w') as f:
35 yaml.safe_dump(users, f)