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