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