@@ 2869-2905 (lines=37) @@ | ||
2866 | 'img': [i['src'] for i in imgs], |
|
2867 | 'month': day.month, |
|
2868 | 'year': day.year, |
|
2869 | 'day': day.day, |
|
2870 | 'title': title, |
|
2871 | 'tags': tags, |
|
2872 | 'alt': alt, |
|
2873 | 'author': author, |
|
2874 | } |
|
2875 | ||
2876 | ||
2877 | class AHamADay(GenericNavigableComic): |
|
2878 | """Class to retrieve class A Ham A Day comics.""" |
|
2879 | name = 'ham' |
|
2880 | long_name = 'A Ham A Day' |
|
2881 | url = 'http://www.ahammaday.com' |
|
2882 | get_url_from_link = join_cls_url_to_href |
|
2883 | get_first_comic_link = simulate_first_link |
|
2884 | first_url = 'http://www.ahammaday.com/today/3/6/french' |
|
2885 | ||
2886 | @classmethod |
|
2887 | def get_navi_link(cls, last_soup, next_): |
|
2888 | """Get link to next or previous comic.""" |
|
2889 | # prev is next / next is prev |
|
2890 | return last_soup.find('li', class_='previous' if next_ else 'next').find('a') |
|
2891 | ||
2892 | @classmethod |
|
2893 | def get_comic_info(cls, soup, link): |
|
2894 | """Get information about a particular comics.""" |
|
2895 | date_str = soup.find('time', class_='published')['datetime'] |
|
2896 | day = string_to_date(date_str, "%Y-%m-%d") |
|
2897 | author = soup.find('span', class_='blog-author').find('a').string |
|
2898 | title = soup.find('meta', property='og:title')['content'] |
|
2899 | imgs = soup.find_all('meta', itemprop='image') |
|
2900 | return { |
|
2901 | 'img': [i['content'] for i in imgs], |
|
2902 | 'title': title, |
|
2903 | 'author': author, |
|
2904 | 'day': day.day, |
|
2905 | 'month': day.month, |
|
2906 | 'year': day.year, |
|
2907 | } |
|
2908 | ||
@@ 758-792 (lines=35) @@ | ||
755 | get_first_comic_link = simulate_first_link |
|
756 | first_url = 'https://garfield.com/comic/1978/06/19' |
|
757 | ||
758 | @classmethod |
|
759 | def get_navi_link(cls, last_soup, next_): |
|
760 | """Get link to next or previous comic.""" |
|
761 | return last_soup.find('a', class_='comic-arrow-right' if next_ else 'comic-arrow-left') |
|
762 | ||
763 | @classmethod |
|
764 | def get_comic_info(cls, soup, link): |
|
765 | """Get information about a particular comics.""" |
|
766 | url = cls.get_url_from_link(link) |
|
767 | date_re = re.compile('^%s/comic/([0-9]*)/([0-9]*)/([0-9]*)' % cls.url) |
|
768 | year, month, day = [int(s) for s in date_re.match(url).groups()] |
|
769 | imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive') |
|
770 | return { |
|
771 | 'month': month, |
|
772 | 'year': year, |
|
773 | 'day': day, |
|
774 | 'img': [i['src'] for i in imgs], |
|
775 | } |
|
776 | ||
777 | ||
778 | class Dilbert(GenericNavigableComic): |
|
779 | """Class to retrieve Dilbert comics.""" |
|
780 | # Also on http://www.gocomics.com/dilbert-classics |
|
781 | name = 'dilbert' |
|
782 | long_name = 'Dilbert' |
|
783 | url = 'http://dilbert.com' |
|
784 | get_url_from_link = join_cls_url_to_href |
|
785 | get_first_comic_link = simulate_first_link |
|
786 | first_url = 'http://dilbert.com/strip/1989-04-16' |
|
787 | ||
788 | @classmethod |
|
789 | def get_navi_link(cls, last_soup, next_): |
|
790 | """Get link to next or previous comic.""" |
|
791 | link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left') |
|
792 | return link.find('a') if link else None |
|
793 | ||
794 | @classmethod |
|
795 | def get_comic_info(cls, soup, link): |