|
@@ 1327-1353 (lines=27) @@
|
| 1324 |
|
"""Class to retrieve Butter Safe comics.""" |
| 1325 |
|
name = 'butter' |
| 1326 |
|
long_name = 'ButterSafe' |
| 1327 |
|
url = 'http://buttersafe.com' |
| 1328 |
|
get_url_from_archive_element = get_href |
| 1329 |
|
comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
| 1330 |
|
|
| 1331 |
|
@classmethod |
| 1332 |
|
def get_archive_elements(cls): |
| 1333 |
|
archive_url = urljoin_wrapper(cls.url, 'archive/') |
| 1334 |
|
return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
| 1335 |
|
|
| 1336 |
|
@classmethod |
| 1337 |
|
def get_comic_info(cls, soup, link): |
| 1338 |
|
"""Get information about a particular comics.""" |
| 1339 |
|
url = cls.get_url_from_archive_element(link) |
| 1340 |
|
title = link.string |
| 1341 |
|
year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
| 1342 |
|
img = soup.find('div', id='comic').find('img') |
| 1343 |
|
assert img['alt'] == title |
| 1344 |
|
return { |
| 1345 |
|
'title': title, |
| 1346 |
|
'day': day, |
| 1347 |
|
'month': month, |
| 1348 |
|
'year': year, |
| 1349 |
|
'img': [img['src']], |
| 1350 |
|
} |
| 1351 |
|
|
| 1352 |
|
|
| 1353 |
|
class CalvinAndHobbes(GenericComic): |
| 1354 |
|
"""Class to retrieve Calvin and Hobbes comics.""" |
| 1355 |
|
# Also on http://www.gocomics.com/calvinandhobbes/ |
| 1356 |
|
name = 'calvin' |
|
@@ 1393-1414 (lines=22) @@
|
| 1390 |
|
"""Class to retrieve AbstruseGoose Comics.""" |
| 1391 |
|
name = 'abstruse' |
| 1392 |
|
long_name = 'Abstruse Goose' |
| 1393 |
|
url = 'http://abstrusegoose.com' |
| 1394 |
|
get_url_from_archive_element = get_href |
| 1395 |
|
comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
| 1396 |
|
comic_img_re = re.compile('^%s/strips/.*' % url) |
| 1397 |
|
|
| 1398 |
|
@classmethod |
| 1399 |
|
def get_archive_elements(cls): |
| 1400 |
|
archive_url = urljoin_wrapper(cls.url, 'archive') |
| 1401 |
|
return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
| 1402 |
|
|
| 1403 |
|
@classmethod |
| 1404 |
|
def get_comic_info(cls, soup, archive_elt): |
| 1405 |
|
comic_url = cls.get_url_from_archive_element(archive_elt) |
| 1406 |
|
num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
| 1407 |
|
return { |
| 1408 |
|
'num': num, |
| 1409 |
|
'title': archive_elt.string, |
| 1410 |
|
'img': [soup.find('img', src=cls.comic_img_re)['src']] |
| 1411 |
|
} |
| 1412 |
|
|
| 1413 |
|
|
| 1414 |
|
class PhDComics(GenericNavigableComic): |
| 1415 |
|
"""Class to retrieve PHD Comics.""" |
| 1416 |
|
name = 'phd' |
| 1417 |
|
long_name = 'PhD Comics' |