@@ 3097-3133 (lines=37) @@ | ||
3094 | imgs = soup.find('figure').find_all('img') |
|
3095 | return { |
|
3096 | 'title': title, |
|
3097 | 'description': desc, |
|
3098 | 'day': day.day, |
|
3099 | 'month': day.month, |
|
3100 | 'year': day.year, |
|
3101 | 'img': [i['src'] for i in imgs], |
|
3102 | } |
|
3103 | ||
3104 | ||
3105 | class LittleLifeLines(GenericNavigableComic): |
|
3106 | """Class to retrieve Little Life Lines comics.""" |
|
3107 | # Also on https://little-life-lines.tumblr.com |
|
3108 | name = 'life' |
|
3109 | long_name = 'Little Life Lines' |
|
3110 | url = 'http://www.littlelifelines.com' |
|
3111 | get_url_from_link = join_cls_url_to_href |
|
3112 | get_first_comic_link = simulate_first_link |
|
3113 | first_url = 'http://www.littlelifelines.com/comics/well-done' |
|
3114 | ||
3115 | @classmethod |
|
3116 | def get_navi_link(cls, last_soup, next_): |
|
3117 | """Get link to next or previous comic.""" |
|
3118 | # prev is next / next is prev |
|
3119 | li = last_soup.find('li', class_='prev' if next_ else 'next') |
|
3120 | return li.find('a') if li else None |
|
3121 | ||
3122 | @classmethod |
|
3123 | def get_comic_info(cls, soup, link): |
|
3124 | """Get information about a particular comics.""" |
|
3125 | title = soup.find('meta', property='og:title')['content'] |
|
3126 | desc = soup.find('meta', property='og:description')['content'] |
|
3127 | date_str = soup.find('time', class_='published')['datetime'] |
|
3128 | day = string_to_date(date_str, "%Y-%m-%d") |
|
3129 | author = soup.find('a', rel='author').string |
|
3130 | div_content = soup.find('div', class_="body entry-content") |
|
3131 | imgs = div_content.find_all('img') |
|
3132 | imgs = [i for i in imgs if i.get('src') is not None] |
|
3133 | alt = imgs[0]['alt'] |
|
3134 | return { |
|
3135 | 'title': title, |
|
3136 | 'alt': alt, |
|
@@ 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 |