]> gitweb.pimeys.fr Git - today.git/blob - comics.py
Modularisation++ : sagas.py pour xantah
[today.git] / comics.py
1 #!/usr/bin/env python
2 # -*- encoding: utf-8 -*-
3
4 """ Gathering des webcomics """
5
6 import urllib
7 import re
8 from lxml import etree
9
10 def last_xkcd():
11 p = urllib.urlopen("http://xkcd.com")
12 t = p.read()
13 current_id = int(re.findall("Permanent link to this comic: http://xkcd.com/(.*?)/", t)[0])
14 return current_id
15
16 def last_jl8():
17 rss = urllib.urlopen("http://limbero.org/jl8/rss/")
18 t = rss.read()
19 x = etree.fromstring(t)
20 links = x.xpath("//link")
21 maxnum = links[1].text.split("/")[-1]
22 maxnum = int(maxnum)
23 return maxnum
24
25 functions = {
26 "xkcd" : last_xkcd,
27 "dc" : last_jl8,
28 }