dosage/dosagelib/plugins/u.py

40 lines
1.8 KiB
Python
Raw Normal View History

# -*- coding: iso-8859-1 -*-
# Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs
2012-11-21 20:57:26 +00:00
# Copyright (C) 2012 Bastian Kleineidam
2012-11-26 06:13:32 +00:00
from re import compile
2012-06-20 19:58:13 +00:00
2012-10-11 10:03:12 +00:00
from ..scraper import _BasicScraper
from ..helpers import bounceStarter, indirectStarter
2012-12-04 06:02:40 +00:00
from ..util import getQueryParams, tagre
2012-06-20 19:58:13 +00:00
class Undertow(_BasicScraper):
2012-11-13 18:10:19 +00:00
stripUrl = 'http://undertow.dreamshards.org/%s'
2012-12-04 06:02:40 +00:00
imageSearch = compile(tagre("img", "src", r'([^"]+\.jpg)'))
2012-06-20 19:58:13 +00:00
prevSearch = compile(r'href="(.+?)".+?teynpoint')
help = 'Index format: good luck !'
starter = indirectStarter('http://undertow.dreamshards.org/',
compile(r'href="(.+?)".+?Most recent page'))
class UnicornJelly(_BasicScraper):
latestUrl = 'http://unicornjelly.com/uni666.html'
2012-11-13 18:10:19 +00:00
stripUrl = 'http://unicornjelly.com/uni%s.html'
2012-06-20 19:58:13 +00:00
imageSearch = compile(r'</TABLE>(?:<FONT COLOR="BLACK">)?<IMG SRC="(images/[^"]+)" WIDTH=')
prevSearch = compile(r'<A HREF="(uni\d{3}[bcs]?\.html)">(<FONT COLOR="BLACK">)?<IMG SRC="images/back00\.gif"')
help = 'Index format: nnn'
2012-12-13 20:05:27 +00:00
# XXX disallowed by robots.txt
class _UserFriendly(_BasicScraper):
2012-06-20 19:58:13 +00:00
starter = bounceStarter('http://ars.userfriendly.org/cartoons/?mode=classic', compile(r'<area shape="rect" href="(/cartoons/\?id=\d{8}&mode=classic)" coords="[\d, ]+?" alt="">'))
2012-11-13 18:10:19 +00:00
stripUrl = 'http://ars.userfriendly.org/cartoons/?id=%s&mode=classic'
2012-12-07 23:45:18 +00:00
imageSearch = compile(r'<img border="0" src="\s*(http://www.userfriendly.org/cartoons/archives/\d{2}\w{3}/.+?\.gif)"')
2012-06-20 19:58:13 +00:00
prevSearch = compile(r'<area shape="rect" href="(/cartoons/\?id=\d{8}&mode=classic)" coords="[\d, ]+?" alt="Previous Cartoon">')
help = 'Index format: yyyymmdd'
@classmethod
def namer(cls, imageUrl, pageUrl):
return 'uf%s' % (getQueryParams(pageUrl)['id'][0][2:],)