2012-06-20 20:41:04 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
|
|
|
# Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs
|
2012-06-20 19:58:13 +00:00
|
|
|
from re import compile
|
|
|
|
|
2012-10-11 10:03:12 +00:00
|
|
|
from ..scraper import _BasicScraper
|
|
|
|
from ..helpers import bounceStarter
|
|
|
|
|
2012-06-20 19:58:13 +00:00
|
|
|
|
|
|
|
class xkcd(_BasicScraper):
|
|
|
|
starter = bounceStarter('http://xkcd.com/', compile(r'<a rel="next" href="(/?\d+/?)"[^>]*>Next'))
|
2012-11-13 18:10:19 +00:00
|
|
|
stripUrl = 'http://xkcd.com/c%s.html'
|
2012-06-20 19:58:13 +00:00
|
|
|
imageSearch = compile(r'<img[^<]+src="(http://imgs.xkcd.com/comics/[^<>"]+)"')
|
|
|
|
prevSearch = compile(r'<a rel="prev" href="(/?\d+/?)"[^>]*>< Prev')
|
|
|
|
help = 'Index format: n (unpadded)'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def namer(cls, imageUrl, pageUrl):
|
|
|
|
index = int(pageUrl.rstrip('/').split('/')[-1])
|
|
|
|
name = imageUrl.split('/')[-1].split('.')[0]
|
|
|
|
return 'c%03d-%s' % (index, name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class xkcdSpanish(_BasicScraper):
|
|
|
|
latestUrl = 'http://es.xkcd.com/xkcd-es/'
|
2012-11-13 18:10:19 +00:00
|
|
|
stripUrl = 'http://es.xkcd.com/xkcd-es/strips/%s/'
|
2012-06-20 19:58:13 +00:00
|
|
|
imageSearch = compile(r'src="(/site_media/strips/.+?)"')
|
|
|
|
prevSearch = compile(r'<a rel="prev" href="(http://es.xkcd.com/xkcd-es/strips/.+?)">Anterior</a>')
|
|
|
|
help = 'Index format: stripname'
|