|
@@ 1386-1412 (lines=27) @@
|
| 1383 |
|
} |
| 1384 |
|
|
| 1385 |
|
|
| 1386 |
|
class ButterSafe(GenericListableComic): |
| 1387 |
|
"""Class to retrieve Butter Safe comics.""" |
| 1388 |
|
name = 'butter' |
| 1389 |
|
long_name = 'ButterSafe' |
| 1390 |
|
url = 'http://buttersafe.com' |
| 1391 |
|
get_url_from_archive_element = get_href |
| 1392 |
|
comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
| 1393 |
|
|
| 1394 |
|
@classmethod |
| 1395 |
|
def get_archive_elements(cls): |
| 1396 |
|
archive_url = urljoin_wrapper(cls.url, 'archive/') |
| 1397 |
|
return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
| 1398 |
|
|
| 1399 |
|
@classmethod |
| 1400 |
|
def get_comic_info(cls, soup, link): |
| 1401 |
|
"""Get information about a particular comics.""" |
| 1402 |
|
url = cls.get_url_from_archive_element(link) |
| 1403 |
|
title = link.string |
| 1404 |
|
year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
| 1405 |
|
img = soup.find('div', id='comic').find('img') |
| 1406 |
|
assert img['alt'] == title |
| 1407 |
|
return { |
| 1408 |
|
'title': title, |
| 1409 |
|
'day': day, |
| 1410 |
|
'month': month, |
| 1411 |
|
'year': year, |
| 1412 |
|
'img': [img['src']], |
| 1413 |
|
} |
| 1414 |
|
|
| 1415 |
|
|
|
@@ 1452-1473 (lines=22) @@
|
| 1449 |
|
last_date = comic_date |
| 1450 |
|
|
| 1451 |
|
|
| 1452 |
|
class AbstruseGoose(GenericListableComic): |
| 1453 |
|
"""Class to retrieve AbstruseGoose Comics.""" |
| 1454 |
|
name = 'abstruse' |
| 1455 |
|
long_name = 'Abstruse Goose' |
| 1456 |
|
url = 'http://abstrusegoose.com' |
| 1457 |
|
get_url_from_archive_element = get_href |
| 1458 |
|
comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
| 1459 |
|
comic_img_re = re.compile('^%s/strips/.*' % url) |
| 1460 |
|
|
| 1461 |
|
@classmethod |
| 1462 |
|
def get_archive_elements(cls): |
| 1463 |
|
archive_url = urljoin_wrapper(cls.url, 'archive') |
| 1464 |
|
return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
| 1465 |
|
|
| 1466 |
|
@classmethod |
| 1467 |
|
def get_comic_info(cls, soup, archive_elt): |
| 1468 |
|
comic_url = cls.get_url_from_archive_element(archive_elt) |
| 1469 |
|
num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
| 1470 |
|
return { |
| 1471 |
|
'num': num, |
| 1472 |
|
'title': archive_elt.string, |
| 1473 |
|
'img': [soup.find('img', src=cls.comic_img_re)['src']] |
| 1474 |
|
} |
| 1475 |
|
|
| 1476 |
|
|