|
@@ 763-799 (lines=37) @@
|
| 760 |
|
} |
| 761 |
|
|
| 762 |
|
|
| 763 |
|
class Dilbert(GenericNavigableComic): |
| 764 |
|
"""Class to retrieve Dilbert comics.""" |
| 765 |
|
# Also on http://www.gocomics.com/dilbert-classics |
| 766 |
|
name = 'dilbert' |
| 767 |
|
long_name = 'Dilbert' |
| 768 |
|
url = 'http://dilbert.com' |
| 769 |
|
get_url_from_link = join_cls_url_to_href |
| 770 |
|
|
| 771 |
|
@classmethod |
| 772 |
|
def get_first_comic_link(cls): |
| 773 |
|
"""Get link to first comics.""" |
| 774 |
|
return {'href': 'http://dilbert.com/strip/1989-04-16'} |
| 775 |
|
|
| 776 |
|
@classmethod |
| 777 |
|
def get_navi_link(cls, last_soup, next_): |
| 778 |
|
link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left') |
| 779 |
|
return link.find('a') if link else None |
| 780 |
|
|
| 781 |
|
@classmethod |
| 782 |
|
def get_comic_info(cls, soup, link): |
| 783 |
|
"""Get information about a particular comics.""" |
| 784 |
|
title = soup.find('meta', property='og:title')['content'] |
| 785 |
|
imgs = soup.find_all('meta', property='og:image') |
| 786 |
|
desc = soup.find('meta', property='og:description')['content'] |
| 787 |
|
date_str = soup.find('meta', property='article:publish_date')['content'] |
| 788 |
|
day = string_to_date(date_str, "%B %d, %Y") |
| 789 |
|
author = soup.find('meta', property='article:author')['content'] |
| 790 |
|
tags = soup.find('meta', property='article:tag')['content'] |
| 791 |
|
return { |
| 792 |
|
'title': title, |
| 793 |
|
'description': desc, |
| 794 |
|
'img': [i['content'] for i in imgs], |
| 795 |
|
'author': author, |
| 796 |
|
'tags': tags, |
| 797 |
|
'day': day.day, |
| 798 |
|
'month': day.month, |
| 799 |
|
'year': day.year |
| 800 |
|
} |
| 801 |
|
|
| 802 |
|
|
|
@@ 2902-2940 (lines=39) @@
|
| 2899 |
|
} |
| 2900 |
|
|
| 2901 |
|
|
| 2902 |
|
class LittleLifeLines(GenericNavigableComic): |
| 2903 |
|
"""Class to retrieve Little Life Lines comics.""" |
| 2904 |
|
name = 'life' |
| 2905 |
|
long_name = 'Little Life Lines' |
| 2906 |
|
url = 'http://www.littlelifelines.com' |
| 2907 |
|
get_url_from_link = join_cls_url_to_href |
| 2908 |
|
|
| 2909 |
|
@classmethod |
| 2910 |
|
def get_first_comic_link(cls): |
| 2911 |
|
"""Get link to first comics.""" |
| 2912 |
|
return {'href': 'http://www.littlelifelines.com/comics/well-done'} |
| 2913 |
|
|
| 2914 |
|
@classmethod |
| 2915 |
|
def get_navi_link(cls, last_soup, next_): |
| 2916 |
|
# prev is next / next is prev |
| 2917 |
|
li = last_soup.find('li', class_='prev' if next_ else 'next') |
| 2918 |
|
return li.find('a') if li else None |
| 2919 |
|
|
| 2920 |
|
@classmethod |
| 2921 |
|
def get_comic_info(cls, soup, link): |
| 2922 |
|
"""Get information about a particular comics.""" |
| 2923 |
|
title = soup.find('meta', property='og:title')['content'] |
| 2924 |
|
desc = soup.find('meta', property='og:description')['content'] |
| 2925 |
|
date_str = soup.find('time', class_='published')['datetime'] |
| 2926 |
|
day = string_to_date(date_str, "%Y-%m-%d") |
| 2927 |
|
author = soup.find('a', rel='author').string |
| 2928 |
|
div_content = soup.find('div', class_="body entry-content") |
| 2929 |
|
imgs = div_content.find_all('img') |
| 2930 |
|
imgs = [i for i in imgs if i.get('src') is not None] |
| 2931 |
|
alt = imgs[0]['alt'] |
| 2932 |
|
return { |
| 2933 |
|
'title': title, |
| 2934 |
|
'alt': alt, |
| 2935 |
|
'description': desc, |
| 2936 |
|
'author': author, |
| 2937 |
|
'day': day.day, |
| 2938 |
|
'month': day.month, |
| 2939 |
|
'year': day.year, |
| 2940 |
|
'img': [i['src'] for i in imgs], |
| 2941 |
|
} |
| 2942 |
|
|
| 2943 |
|
|