@@ 2999-3035 (lines=37) @@ | ||
2996 | class AHammADay(GenericEmptyComic, GenericNavigableComic): |
|
2997 | """Class to retrieve class A Hamm A Day comics.""" |
|
2998 | name = 'hamm' |
|
2999 | long_name = 'A Hamm A Day' |
|
3000 | url = 'http://www.ahammaday.com' |
|
3001 | get_url_from_link = join_cls_url_to_href |
|
3002 | get_first_comic_link = simulate_first_link |
|
3003 | first_url = 'http://www.ahammaday.com/today/3/6/french' |
|
3004 | ||
3005 | @classmethod |
|
3006 | def get_navi_link(cls, last_soup, next_): |
|
3007 | """Get link to next or previous comic.""" |
|
3008 | # prev is next / next is prev |
|
3009 | return last_soup.find('li', class_='previous' if next_ else 'next').find('a') |
|
3010 | ||
3011 | @classmethod |
|
3012 | def get_comic_info(cls, soup, link): |
|
3013 | """Get information about a particular comics.""" |
|
3014 | date_str = soup.find('time', class_='published')['datetime'] |
|
3015 | day = string_to_date(date_str, "%Y-%m-%d") |
|
3016 | author = soup.find('span', class_='blog-author').find('a').string |
|
3017 | title = soup.find('meta', property='og:title')['content'] |
|
3018 | imgs = soup.find_all('meta', itemprop='image') |
|
3019 | return { |
|
3020 | 'img': [i['content'] for i in imgs], |
|
3021 | 'title': title, |
|
3022 | 'author': author, |
|
3023 | 'day': day.day, |
|
3024 | 'month': day.month, |
|
3025 | 'year': day.year, |
|
3026 | } |
|
3027 | ||
3028 | ||
3029 | class LittleLifeLines(GenericNavigableComic): |
|
3030 | """Class to retrieve Little Life Lines comics.""" |
|
3031 | # Also on https://little-life-lines.tumblr.com |
|
3032 | name = 'life' |
|
3033 | long_name = 'Little Life Lines' |
|
3034 | url = 'http://www.littlelifelines.com' |
|
3035 | get_url_from_link = join_cls_url_to_href |
|
3036 | get_first_comic_link = simulate_first_link |
|
3037 | first_url = 'http://www.littlelifelines.com/comics/well-done' |
|
3038 | ||
@@ 782-816 (lines=35) @@ | ||
779 | 'img': [i['src'] for i in imgs], |
|
780 | } |
|
781 | ||
782 | ||
783 | class Dilbert(GenericNavigableComic): |
|
784 | """Class to retrieve Dilbert comics.""" |
|
785 | # Also on http://www.gocomics.com/dilbert-classics |
|
786 | name = 'dilbert' |
|
787 | long_name = 'Dilbert' |
|
788 | url = 'http://dilbert.com' |
|
789 | get_url_from_link = join_cls_url_to_href |
|
790 | get_first_comic_link = simulate_first_link |
|
791 | first_url = 'http://dilbert.com/strip/1989-04-16' |
|
792 | ||
793 | @classmethod |
|
794 | def get_navi_link(cls, last_soup, next_): |
|
795 | """Get link to next or previous comic.""" |
|
796 | link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left') |
|
797 | return link.find('a') if link else None |
|
798 | ||
799 | @classmethod |
|
800 | def get_comic_info(cls, soup, link): |
|
801 | """Get information about a particular comics.""" |
|
802 | title = soup.find('meta', property='og:title')['content'] |
|
803 | imgs = soup.find_all('meta', property='og:image') |
|
804 | desc = soup.find('meta', property='og:description')['content'] |
|
805 | date_str = soup.find('meta', property='article:publish_date')['content'] |
|
806 | day = string_to_date(date_str, "%B %d, %Y") |
|
807 | author = soup.find('meta', property='article:author')['content'] |
|
808 | tags = soup.find('meta', property='article:tag')['content'] |
|
809 | return { |
|
810 | 'title': title, |
|
811 | 'description': desc, |
|
812 | 'img': [i['content'] for i in imgs], |
|
813 | 'author': author, |
|
814 | 'tags': tags, |
|
815 | 'day': day.day, |
|
816 | 'month': day.month, |
|
817 | 'year': day.year |
|
818 | } |
|
819 |