@@ 2869-2905 (lines=37) @@ | ||
2866 | } |
|
2867 | ||
2868 | ||
2869 | class LittleLifeLines(GenericNavigableComic): |
|
2870 | """Class to retrieve Little Life Lines comics.""" |
|
2871 | name = 'life' |
|
2872 | long_name = 'Little Life Lines' |
|
2873 | url = 'http://www.littlelifelines.com' |
|
2874 | get_url_from_link = join_cls_url_to_href |
|
2875 | get_first_comic_link = simulate_first_link |
|
2876 | first_url = 'http://www.littlelifelines.com/comics/well-done' |
|
2877 | ||
2878 | @classmethod |
|
2879 | def get_navi_link(cls, last_soup, next_): |
|
2880 | """Get link to next or previous comic.""" |
|
2881 | # prev is next / next is prev |
|
2882 | li = last_soup.find('li', class_='prev' if next_ else 'next') |
|
2883 | return li.find('a') if li else None |
|
2884 | ||
2885 | @classmethod |
|
2886 | def get_comic_info(cls, soup, link): |
|
2887 | """Get information about a particular comics.""" |
|
2888 | title = soup.find('meta', property='og:title')['content'] |
|
2889 | desc = soup.find('meta', property='og:description')['content'] |
|
2890 | date_str = soup.find('time', class_='published')['datetime'] |
|
2891 | day = string_to_date(date_str, "%Y-%m-%d") |
|
2892 | author = soup.find('a', rel='author').string |
|
2893 | div_content = soup.find('div', class_="body entry-content") |
|
2894 | imgs = div_content.find_all('img') |
|
2895 | imgs = [i for i in imgs if i.get('src') is not None] |
|
2896 | alt = imgs[0]['alt'] |
|
2897 | return { |
|
2898 | 'title': title, |
|
2899 | 'alt': alt, |
|
2900 | 'description': desc, |
|
2901 | 'author': author, |
|
2902 | 'day': day.day, |
|
2903 | 'month': day.month, |
|
2904 | 'year': day.year, |
|
2905 | 'img': [i['src'] for i in imgs], |
|
2906 | } |
|
2907 | ||
2908 | ||
@@ 758-792 (lines=35) @@ | ||
755 | } |
|
756 | ||
757 | ||
758 | class Dilbert(GenericNavigableComic): |
|
759 | """Class to retrieve Dilbert comics.""" |
|
760 | # Also on http://www.gocomics.com/dilbert-classics |
|
761 | name = 'dilbert' |
|
762 | long_name = 'Dilbert' |
|
763 | url = 'http://dilbert.com' |
|
764 | get_url_from_link = join_cls_url_to_href |
|
765 | get_first_comic_link = simulate_first_link |
|
766 | first_url = 'http://dilbert.com/strip/1989-04-16' |
|
767 | ||
768 | @classmethod |
|
769 | def get_navi_link(cls, last_soup, next_): |
|
770 | """Get link to next or previous comic.""" |
|
771 | link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left') |
|
772 | return link.find('a') if link else None |
|
773 | ||
774 | @classmethod |
|
775 | def get_comic_info(cls, soup, link): |
|
776 | """Get information about a particular comics.""" |
|
777 | title = soup.find('meta', property='og:title')['content'] |
|
778 | imgs = soup.find_all('meta', property='og:image') |
|
779 | desc = soup.find('meta', property='og:description')['content'] |
|
780 | date_str = soup.find('meta', property='article:publish_date')['content'] |
|
781 | day = string_to_date(date_str, "%B %d, %Y") |
|
782 | author = soup.find('meta', property='article:author')['content'] |
|
783 | tags = soup.find('meta', property='article:tag')['content'] |
|
784 | return { |
|
785 | 'title': title, |
|
786 | 'description': desc, |
|
787 | 'img': [i['content'] for i in imgs], |
|
788 | 'author': author, |
|
789 | 'tags': tags, |
|
790 | 'day': day.day, |
|
791 | 'month': day.month, |
|
792 | 'year': day.year |
|
793 | } |
|
794 | ||
795 |