@@ 1407-1433 (lines=27) @@ | ||
1404 | } |
|
1405 | ||
1406 | ||
1407 | class ButterSafe(GenericListableComic): |
|
1408 | """Class to retrieve Butter Safe comics.""" |
|
1409 | name = 'butter' |
|
1410 | long_name = 'ButterSafe' |
|
1411 | url = 'http://buttersafe.com' |
|
1412 | get_url_from_archive_element = get_href |
|
1413 | comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
|
1414 | ||
1415 | @classmethod |
|
1416 | def get_archive_elements(cls): |
|
1417 | archive_url = urljoin_wrapper(cls.url, 'archive/') |
|
1418 | return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
|
1419 | ||
1420 | @classmethod |
|
1421 | def get_comic_info(cls, soup, link): |
|
1422 | """Get information about a particular comics.""" |
|
1423 | url = cls.get_url_from_archive_element(link) |
|
1424 | title = link.string |
|
1425 | year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
|
1426 | img = soup.find('div', id='comic').find('img') |
|
1427 | assert img['alt'] == title |
|
1428 | return { |
|
1429 | 'title': title, |
|
1430 | 'day': day, |
|
1431 | 'month': month, |
|
1432 | 'year': year, |
|
1433 | 'img': [img['src']], |
|
1434 | } |
|
1435 | ||
1436 | ||
@@ 1473-1495 (lines=23) @@ | ||
1470 | last_date = comic_date |
|
1471 | ||
1472 | ||
1473 | class AbstruseGoose(GenericListableComic): |
|
1474 | """Class to retrieve AbstruseGoose Comics.""" |
|
1475 | name = 'abstruse' |
|
1476 | long_name = 'Abstruse Goose' |
|
1477 | url = 'http://abstrusegoose.com' |
|
1478 | get_url_from_archive_element = get_href |
|
1479 | comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
|
1480 | comic_img_re = re.compile('^%s/strips/.*' % url) |
|
1481 | ||
1482 | @classmethod |
|
1483 | def get_archive_elements(cls): |
|
1484 | archive_url = urljoin_wrapper(cls.url, 'archive') |
|
1485 | return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
|
1486 | ||
1487 | @classmethod |
|
1488 | def get_comic_info(cls, soup, archive_elt): |
|
1489 | comic_url = cls.get_url_from_archive_element(archive_elt) |
|
1490 | num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
|
1491 | imgs = soup.find_all('img', src=cls.comic_img_re) |
|
1492 | return { |
|
1493 | 'num': num, |
|
1494 | 'title': archive_elt.string, |
|
1495 | 'img': [i['src'] for i in imgs], |
|
1496 | } |
|
1497 | ||
1498 |