|
@@ 543-569 (lines=27) @@
|
| 540 |
|
} |
| 541 |
|
|
| 542 |
|
|
| 543 |
|
class SpaceAvalanche(GenericNavigableComic): |
| 544 |
|
"""Class to retrieve Space Avalanche comics.""" |
| 545 |
|
name = 'avalanche' |
| 546 |
|
long_name = 'Space Avalanche' |
| 547 |
|
url = 'http://www.spaceavalanche.com' |
| 548 |
|
get_navi_link = get_link_rel_next |
| 549 |
|
|
| 550 |
|
@classmethod |
| 551 |
|
def get_first_comic_link(cls): |
| 552 |
|
"""Get link to first comics.""" |
| 553 |
|
return {'href': "http://www.spaceavalanche.com/2009/02/02/irish-sea/", 'title': "Irish Sea"} |
| 554 |
|
|
| 555 |
|
@classmethod |
| 556 |
|
def get_comic_info(cls, soup, link): |
| 557 |
|
"""Get information about a particular comics.""" |
| 558 |
|
url_date_re = re.compile('.*/([0-9]*)/([0-9]*)/([0-9]*)/.*$') |
| 559 |
|
title = link['title'] |
| 560 |
|
url = cls.get_url_from_link(link) |
| 561 |
|
year, month, day = [int(s) |
| 562 |
|
for s in url_date_re.match(url).groups()] |
| 563 |
|
imgs = soup.find("div", class_="entry").find_all("img") |
| 564 |
|
return { |
| 565 |
|
'title': title, |
| 566 |
|
'day': day, |
| 567 |
|
'month': month, |
| 568 |
|
'year': year, |
| 569 |
|
'img': [i['src'] for i in imgs], |
| 570 |
|
} |
| 571 |
|
|
| 572 |
|
|
|
@@ 752-777 (lines=26) @@
|
| 749 |
|
} |
| 750 |
|
|
| 751 |
|
|
| 752 |
|
class Garfield(GenericNavigableComic): |
| 753 |
|
"""Class to retrieve Garfield comics.""" |
| 754 |
|
# Also on http://www.gocomics.com/garfield |
| 755 |
|
name = 'garfield' |
| 756 |
|
long_name = 'Garfield' |
| 757 |
|
url = 'https://garfield.com' |
| 758 |
|
get_first_comic_link = simulate_first_link |
| 759 |
|
first_url = 'https://garfield.com/comic/1978/06/19' |
| 760 |
|
|
| 761 |
|
@classmethod |
| 762 |
|
def get_navi_link(cls, last_soup, next_): |
| 763 |
|
"""Get link to next or previous comic.""" |
| 764 |
|
return last_soup.find('a', class_='comic-arrow-right' if next_ else 'comic-arrow-left') |
| 765 |
|
|
| 766 |
|
@classmethod |
| 767 |
|
def get_comic_info(cls, soup, link): |
| 768 |
|
"""Get information about a particular comics.""" |
| 769 |
|
url = cls.get_url_from_link(link) |
| 770 |
|
date_re = re.compile('^%s/comic/([0-9]*)/([0-9]*)/([0-9]*)' % cls.url) |
| 771 |
|
year, month, day = [int(s) for s in date_re.match(url).groups()] |
| 772 |
|
imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive') |
| 773 |
|
return { |
| 774 |
|
'month': month, |
| 775 |
|
'year': year, |
| 776 |
|
'day': day, |
| 777 |
|
'img': [i['src'] for i in imgs], |
| 778 |
|
} |
| 779 |
|
|
| 780 |
|
|