@@ 831-865 (lines=35) @@ | ||
828 | } |
|
829 | ||
830 | ||
831 | class Dilbert(GenericNavigableComic): |
|
832 | """Class to retrieve Dilbert comics.""" |
|
833 | # Also on http://www.gocomics.com/dilbert-classics |
|
834 | name = 'dilbert' |
|
835 | long_name = 'Dilbert' |
|
836 | url = 'http://dilbert.com' |
|
837 | get_url_from_link = join_cls_url_to_href |
|
838 | get_first_comic_link = simulate_first_link |
|
839 | first_url = 'http://dilbert.com/strip/1989-04-16' |
|
840 | ||
841 | @classmethod |
|
842 | def get_navi_link(cls, last_soup, next_): |
|
843 | """Get link to next or previous comic.""" |
|
844 | link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left') |
|
845 | return link.find('a') if link else None |
|
846 | ||
847 | @classmethod |
|
848 | def get_comic_info(cls, soup, link): |
|
849 | """Get information about a particular comics.""" |
|
850 | title = soup.find('meta', property='og:title')['content'] |
|
851 | imgs = soup.find_all('meta', property='og:image') |
|
852 | desc = soup.find('meta', property='og:description')['content'] |
|
853 | date_str = soup.find('meta', property='article:publish_date')['content'] |
|
854 | day = string_to_date(date_str, "%B %d, %Y") |
|
855 | author = soup.find('meta', property='article:author')['content'] |
|
856 | tags = soup.find('meta', property='article:tag')['content'] |
|
857 | return { |
|
858 | 'title': title, |
|
859 | 'description': desc, |
|
860 | 'img': [i['content'] for i in imgs], |
|
861 | 'author': author, |
|
862 | 'tags': tags, |
|
863 | 'day': day.day, |
|
864 | 'month': day.month, |
|
865 | 'year': day.year |
|
866 | } |
|
867 | ||
868 | ||
@@ 3109-3145 (lines=37) @@ | ||
3106 | class LittleLifeLines(GenericNavigableComic): |
|
3107 | """Class to retrieve Little Life Lines comics.""" |
|
3108 | # Also on https://little-life-lines.tumblr.com |
|
3109 | name = 'life' |
|
3110 | long_name = 'Little Life Lines' |
|
3111 | url = 'http://www.littlelifelines.com' |
|
3112 | get_url_from_link = join_cls_url_to_href |
|
3113 | get_first_comic_link = simulate_first_link |
|
3114 | first_url = 'http://www.littlelifelines.com/comics/well-done' |
|
3115 | ||
3116 | @classmethod |
|
3117 | def get_navi_link(cls, last_soup, next_): |
|
3118 | """Get link to next or previous comic.""" |
|
3119 | # prev is next / next is prev |
|
3120 | li = last_soup.find('li', class_='prev' if next_ else 'next') |
|
3121 | return li.find('a') if li else None |
|
3122 | ||
3123 | @classmethod |
|
3124 | def get_comic_info(cls, soup, link): |
|
3125 | """Get information about a particular comics.""" |
|
3126 | title = soup.find('meta', property='og:title')['content'] |
|
3127 | desc = soup.find('meta', property='og:description')['content'] |
|
3128 | date_str = soup.find('time', class_='published')['datetime'] |
|
3129 | day = string_to_date(date_str, "%Y-%m-%d") |
|
3130 | author = soup.find('a', rel='author').string |
|
3131 | div_content = soup.find('div', class_="body entry-content") |
|
3132 | imgs = div_content.find_all('img') |
|
3133 | imgs = [i for i in imgs if i.get('src') is not None] |
|
3134 | alt = imgs[0]['alt'] |
|
3135 | return { |
|
3136 | 'title': title, |
|
3137 | 'alt': alt, |
|
3138 | 'description': desc, |
|
3139 | 'author': author, |
|
3140 | 'day': day.day, |
|
3141 | 'month': day.month, |
|
3142 | 'year': day.year, |
|
3143 | 'img': [i['src'] for i in imgs], |
|
3144 | } |
|
3145 | ||
3146 | ||
3147 | class GenericWordPressInkblot(GenericNavigableComic): |
|
3148 | """Generic class to retrieve comics using WordPress with Inkblot.""" |