@@ 520-546 (lines=27) @@ | ||
517 | } |
|
518 | ||
519 | ||
520 | class SpaceAvalanche(GenericNavigableComic): |
|
521 | """Class to retrieve Space Avalanche comics.""" |
|
522 | name = 'avalanche' |
|
523 | long_name = 'Space Avalanche' |
|
524 | url = 'http://www.spaceavalanche.com' |
|
525 | get_navi_link = get_link_rel_next |
|
526 | ||
527 | @classmethod |
|
528 | def get_first_comic_link(cls): |
|
529 | """Get link to first comics.""" |
|
530 | return {'href': "http://www.spaceavalanche.com/2009/02/02/irish-sea/", 'title': "Irish Sea"} |
|
531 | ||
532 | @classmethod |
|
533 | def get_comic_info(cls, soup, link): |
|
534 | """Get information about a particular comics.""" |
|
535 | url_date_re = re.compile('.*/([0-9]*)/([0-9]*)/([0-9]*)/.*$') |
|
536 | title = link['title'] |
|
537 | url = cls.get_url_from_link(link) |
|
538 | year, month, day = [int(s) |
|
539 | for s in url_date_re.match(url).groups()] |
|
540 | imgs = soup.find("div", class_="entry").find_all("img") |
|
541 | return { |
|
542 | 'title': title, |
|
543 | 'day': day, |
|
544 | 'month': month, |
|
545 | 'year': year, |
|
546 | 'img': [i['src'] for i in imgs], |
|
547 | } |
|
548 | ||
549 | ||
@@ 729-754 (lines=26) @@ | ||
726 | } |
|
727 | ||
728 | ||
729 | class Garfield(GenericNavigableComic): |
|
730 | """Class to retrieve Garfield comics.""" |
|
731 | # Also on http://www.gocomics.com/garfield |
|
732 | name = 'garfield' |
|
733 | long_name = 'Garfield' |
|
734 | url = 'https://garfield.com' |
|
735 | get_first_comic_link = simulate_first_link |
|
736 | first_url = 'https://garfield.com/comic/1978/06/19' |
|
737 | ||
738 | @classmethod |
|
739 | def get_navi_link(cls, last_soup, next_): |
|
740 | """Get link to next or previous comic.""" |
|
741 | return last_soup.find('a', class_='comic-arrow-right' if next_ else 'comic-arrow-left') |
|
742 | ||
743 | @classmethod |
|
744 | def get_comic_info(cls, soup, link): |
|
745 | """Get information about a particular comics.""" |
|
746 | url = cls.get_url_from_link(link) |
|
747 | date_re = re.compile('^%s/comic/([0-9]*)/([0-9]*)/([0-9]*)' % cls.url) |
|
748 | year, month, day = [int(s) for s in date_re.match(url).groups()] |
|
749 | imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive') |
|
750 | return { |
|
751 | 'month': month, |
|
752 | 'year': year, |
|
753 | 'day': day, |
|
754 | 'img': [i['src'] for i in imgs], |
|
755 | } |
|
756 | ||
757 |