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