|
@@ 520-546 (lines=27) @@
|
| 517 |
|
} |
| 518 |
|
|
| 519 |
|
|
| 520 |
|
class SpaceAvalanche(GenericNavigableComic): |
| 521 |
|
"""Class to retrieve Space Avalanche comics.""" |
| 522 |
|
name = 'avalanche' |
| 523 |
|
long_name = 'Space Avalanche' |
| 524 |
|
url = 'http://www.spaceavalanche.com' |
| 525 |
|
get_navi_link = get_link_rel_next |
| 526 |
|
|
| 527 |
|
@classmethod |
| 528 |
|
def get_first_comic_link(cls): |
| 529 |
|
"""Get link to first comics.""" |
| 530 |
|
return {'href': "http://www.spaceavalanche.com/2009/02/02/irish-sea/", 'title': "Irish Sea"} |
| 531 |
|
|
| 532 |
|
@classmethod |
| 533 |
|
def get_comic_info(cls, soup, link): |
| 534 |
|
"""Get information about a particular comics.""" |
| 535 |
|
url_date_re = re.compile('.*/([0-9]*)/([0-9]*)/([0-9]*)/.*$') |
| 536 |
|
title = link['title'] |
| 537 |
|
url = cls.get_url_from_link(link) |
| 538 |
|
year, month, day = [int(s) |
| 539 |
|
for s in url_date_re.match(url).groups()] |
| 540 |
|
imgs = soup.find("div", class_="entry").find_all("img") |
| 541 |
|
return { |
| 542 |
|
'title': title, |
| 543 |
|
'day': day, |
| 544 |
|
'month': month, |
| 545 |
|
'year': year, |
| 546 |
|
'img': [i['src'] for i in imgs], |
| 547 |
|
} |
| 548 |
|
|
| 549 |
|
|
|
@@ 729-754 (lines=26) @@
|
| 726 |
|
'num': num, |
| 727 |
|
} |
| 728 |
|
|
| 729 |
|
|
| 730 |
|
class Garfield(GenericNavigableComic): |
| 731 |
|
"""Class to retrieve Garfield comics.""" |
| 732 |
|
# Also on http://www.gocomics.com/garfield |
| 733 |
|
name = 'garfield' |
| 734 |
|
long_name = 'Garfield' |
| 735 |
|
url = 'https://garfield.com' |
| 736 |
|
get_first_comic_link = simulate_first_link |
| 737 |
|
first_url = 'https://garfield.com/comic/1978/06/19' |
| 738 |
|
|
| 739 |
|
@classmethod |
| 740 |
|
def get_navi_link(cls, last_soup, next_): |
| 741 |
|
"""Get link to next or previous comic.""" |
| 742 |
|
return last_soup.find('a', class_='comic-arrow-right' if next_ else 'comic-arrow-left') |
| 743 |
|
|
| 744 |
|
@classmethod |
| 745 |
|
def get_comic_info(cls, soup, link): |
| 746 |
|
"""Get information about a particular comics.""" |
| 747 |
|
url = cls.get_url_from_link(link) |
| 748 |
|
date_re = re.compile('^%s/comic/([0-9]*)/([0-9]*)/([0-9]*)' % cls.url) |
| 749 |
|
year, month, day = [int(s) for s in date_re.match(url).groups()] |
| 750 |
|
imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive') |
| 751 |
|
return { |
| 752 |
|
'month': month, |
| 753 |
|
'year': year, |
| 754 |
|
'day': day, |
| 755 |
|
'img': [i['src'] for i in imgs], |
| 756 |
|
} |
| 757 |
|
|