|
@@ 2781-2817 (lines=37) @@
|
| 2778 |
|
date_str = soup.find('span', class_='post-date').string |
| 2779 |
|
day = string_to_date(date_str, "%B %d, %Y") |
| 2780 |
|
return { |
| 2781 |
|
'title': title, |
| 2782 |
|
'alt': alt, |
| 2783 |
|
'author': author, |
| 2784 |
|
'img': [i['src'] for i in imgs], |
| 2785 |
|
'month': day.month, |
| 2786 |
|
'year': day.year, |
| 2787 |
|
'day': day.day, |
| 2788 |
|
} |
| 2789 |
|
|
| 2790 |
|
|
| 2791 |
|
class PainTrainComic(GenericNavigableComic): |
| 2792 |
|
"""Class to retrieve Pain Train Comics.""" |
| 2793 |
|
name = 'paintrain' |
| 2794 |
|
long_name = 'Pain Train Comics' |
| 2795 |
|
url = 'http://paintraincomic.com' |
| 2796 |
|
get_first_comic_link = get_a_navi_navifirst |
| 2797 |
|
get_navi_link = get_link_rel_next |
| 2798 |
|
|
| 2799 |
|
@classmethod |
| 2800 |
|
def get_comic_info(cls, soup, link): |
| 2801 |
|
"""Get information about a particular comics.""" |
| 2802 |
|
title = soup.find('h2', class_='post-title').string |
| 2803 |
|
short_url = soup.find('link', rel='shortlink')['href'] |
| 2804 |
|
short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url) |
| 2805 |
|
num = int(short_url_re.match(short_url).groups()[0]) |
| 2806 |
|
imgs = soup.find('div', id='comic').find_all('img') |
| 2807 |
|
alt = imgs[0]['title'] |
| 2808 |
|
assert all(i['alt'] == i['title'] == alt for i in imgs) |
| 2809 |
|
date_str = soup.find('span', class_='post-date').string |
| 2810 |
|
day = string_to_date(date_str, "%d/%m/%Y") |
| 2811 |
|
return { |
| 2812 |
|
'short_url': short_url, |
| 2813 |
|
'num': num, |
| 2814 |
|
'img': [i['src'] for i in imgs], |
| 2815 |
|
'month': day.month, |
| 2816 |
|
'year': day.year, |
| 2817 |
|
'day': day.day, |
| 2818 |
|
'alt': alt, |
| 2819 |
|
'title': title, |
| 2820 |
|
} |
|
@@ 739-773 (lines=35) @@
|
| 736 |
|
long_name = 'Garfield' |
| 737 |
|
url = 'https://garfield.com' |
| 738 |
|
|
| 739 |
|
@classmethod |
| 740 |
|
def get_first_comic_link(cls): |
| 741 |
|
"""Get link to first comics.""" |
| 742 |
|
return {'href': 'https://garfield.com/comic/1978/06/19'} |
| 743 |
|
|
| 744 |
|
@classmethod |
| 745 |
|
def get_navi_link(cls, last_soup, next_): |
| 746 |
|
return last_soup.find('a', class_='comic-arrow-right' if next_ else 'comic-arrow-left') |
| 747 |
|
|
| 748 |
|
@classmethod |
| 749 |
|
def get_comic_info(cls, soup, link): |
| 750 |
|
"""Get information about a particular comics.""" |
| 751 |
|
url = cls.get_url_from_link(link) |
| 752 |
|
date_re = re.compile('^%s/comic/([0-9]*)/([0-9]*)/([0-9]*)' % cls.url) |
| 753 |
|
year, month, day = [int(s) for s in date_re.match(url).groups()] |
| 754 |
|
imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive') |
| 755 |
|
return { |
| 756 |
|
'month': month, |
| 757 |
|
'year': year, |
| 758 |
|
'day': day, |
| 759 |
|
'img': [i['src'] for i in imgs], |
| 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 |