from re import compile
from ..helpers import _BasicScraper, bounceStarter
class xkcd(_BasicScraper):
starter = bounceStarter('http://xkcd.com/', compile(r']*>Next'))
imageUrl = 'http://xkcd.com/c%s.html'
imageSearch = compile(r'"]+)"')
prevSearch = compile(r']*>< 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/'
imageUrl = 'http://es.xkcd.com/xkcd-es/strips/%s/'
imageSearch = compile(r'src="(/site_media/strips/.+?)"')
prevSearch = compile(r'Anterior')
help = 'Index format: stripname'