@@ 3689-3720 (lines=32) @@ | ||
3686 | } |
|
3687 | ||
3688 | ||
3689 | class GenericSquareSpace(GenericNavigableComic): |
|
3690 | """Generic class to retrieve comics using SquareSpace.""" |
|
3691 | _categories = ('SQUARESPACE', ) |
|
3692 | get_url_from_link = join_cls_url_to_href |
|
3693 | get_first_comic_link = simulate_first_link |
|
3694 | ||
3695 | @classmethod |
|
3696 | def get_navi_link(cls, last_soup, next_): |
|
3697 | """Get link to next or previous comic.""" |
|
3698 | return last_soup.find('a', id='prevLink' if next_ else 'nextLink') |
|
3699 | ||
3700 | @classmethod |
|
3701 | def get_images(cls, soup): |
|
3702 | """Get image URLs for a comic.""" |
|
3703 | raise NotImplementedError |
|
3704 | ||
3705 | @classmethod |
|
3706 | def get_comic_info(cls, soup, link): |
|
3707 | """Get information about a particular comics.""" |
|
3708 | title = soup.find('meta', property='og:title')['content'] |
|
3709 | desc = soup.find('meta', property='og:description')['content'] |
|
3710 | date_str = soup.find('time', itemprop='datePublished')["datetime"] |
|
3711 | day = string_to_date(date_str, "%Y-%m-%d") |
|
3712 | author = soup.find('a', rel='author').string |
|
3713 | return { |
|
3714 | 'title': title, |
|
3715 | 'img': cls.get_images(soup), |
|
3716 | 'month': day.month, |
|
3717 | 'year': day.year, |
|
3718 | 'day': day.day, |
|
3719 | 'author': author, |
|
3720 | 'description': desc, |
|
3721 | } |
|
3722 | ||
3723 | ||
@@ 3537-3566 (lines=30) @@ | ||
3534 | } |
|
3535 | ||
3536 | ||
3537 | class ConsoliaComics(GenericNavigableComic): |
|
3538 | """Class to retrieve Consolia comics.""" |
|
3539 | name = 'consolia' |
|
3540 | long_name = 'consolia' |
|
3541 | url = 'https://consolia-comic.com' |
|
3542 | get_url_from_link = join_cls_url_to_href |
|
3543 | ||
3544 | @classmethod |
|
3545 | def get_first_comic_link(cls): |
|
3546 | """Get link to first comics.""" |
|
3547 | return get_soup_at_url(cls.url).find('a', class_='first') |
|
3548 | ||
3549 | @classmethod |
|
3550 | def get_navi_link(cls, last_soup, next_): |
|
3551 | """Get link to next or previous comic.""" |
|
3552 | return last_soup.find('a', class_='next' if next_ else 'prev') |
|
3553 | ||
3554 | @classmethod |
|
3555 | def get_comic_info(cls, soup, link): |
|
3556 | """Get information about a particular comics.""" |
|
3557 | title = soup.find('meta', property='og:title')['content'] |
|
3558 | date_str = soup.find('time')["datetime"] |
|
3559 | day = string_to_date(date_str, "%Y-%m-%d") |
|
3560 | imgs = soup.find_all('meta', property='og:image') |
|
3561 | return { |
|
3562 | 'title': title, |
|
3563 | 'img': [i['content'] for i in imgs], |
|
3564 | 'day': day.day, |
|
3565 | 'month': day.month, |
|
3566 | 'year': day.year, |
|
3567 | } |
|
3568 | ||
3569 | ||
@@ 3356-3384 (lines=29) @@ | ||
3353 | } |
|
3354 | ||
3355 | ||
3356 | class PomComics(GenericNavigableComic): |
|
3357 | """Class to retrieve PomComics.""" |
|
3358 | name = 'pom' |
|
3359 | long_name = 'Pom Comics / Piece of Me' |
|
3360 | url = 'http://www.pomcomic.com' |
|
3361 | get_url_from_link = join_cls_url_to_href |
|
3362 | ||
3363 | @classmethod |
|
3364 | def get_first_comic_link(cls): |
|
3365 | """Get link to first comics.""" |
|
3366 | return get_soup_at_url(cls.url).find('a', class_='btn-first') |
|
3367 | ||
3368 | @classmethod |
|
3369 | def get_navi_link(cls, last_soup, next_): |
|
3370 | """Get link to next or previous comic.""" |
|
3371 | return last_soup.find('a', class_='btn-next' if next_ else 'btn-prev') |
|
3372 | ||
3373 | @classmethod |
|
3374 | def get_comic_info(cls, soup, link): |
|
3375 | """Get information about a particular comics.""" |
|
3376 | title = soup.find('h1').string |
|
3377 | desc = soup.find('meta', property='og:description')['content'] |
|
3378 | tags = soup.find('meta', attrs={'name': 'keywords'})['content'] |
|
3379 | imgs = soup.find('div', class_='comic').find_all('img') |
|
3380 | return { |
|
3381 | 'title': title, |
|
3382 | 'desc': desc, |
|
3383 | 'tags': tags, |
|
3384 | 'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs], |
|
3385 | } |
|
3386 | ||
3387 |