X-Git-Url: http://gitweb.pimeys.fr/?p=today.git;a=blobdiff_plain;f=comics.py;fp=comics.py;h=d6505946e2951b47eeaad04be4856a17c29653e5;hp=0000000000000000000000000000000000000000;hb=f858db9ed9baa860032d2777838aa029c0cb99b9;hpb=fdcee57ada724242faa407bb6ba752135ec14316 diff --git a/comics.py b/comics.py new file mode 100644 index 0000000..d650594 --- /dev/null +++ b/comics.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +""" Gathering des webcomics """ + +import urllib +import re +from lxml import etree + +def last_xkcd(): + p = urllib.urlopen("http://xkcd.com") + t = p.read() + current_id = int(re.findall("Permanent link to this comic: http://xkcd.com/(.*?)/", t)[0]) + return current_id + +def last_jl8(): + rss = urllib.urlopen("http://limbero.org/jl8/rss/") + t = rss.read() + x = etree.fromstring(t) + links = x.xpath("//link") + maxnum = links[1].text.split("/")[-1] + maxnum = int(maxnum) + return maxnum + +functions = { + "xkcd" : last_xkcd, + "dc" : last_jl8, + }