|
@@ 543-569 (lines=27) @@
|
| 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 |
|
|
| 550 |
|
class ZenPencils(GenericNavigableComic): |
| 551 |
|
"""Class to retrieve ZenPencils comics.""" |
| 552 |
|
# Also on http://zenpencils.tumblr.com |
| 553 |
|
# Also on http://www.gocomics.com/zen-pencils |
| 554 |
|
name = 'zenpencils' |
| 555 |
|
long_name = 'Zen Pencils' |
| 556 |
|
url = 'http://zenpencils.com' |
| 557 |
|
get_navi_link = get_link_rel_next |
| 558 |
|
get_first_comic_link = simulate_first_link |
| 559 |
|
first_url = "http://zenpencils.com/comic/1-ralph-waldo-emerson-make-them-cry/" |
| 560 |
|
|
| 561 |
|
@classmethod |
| 562 |
|
def get_comic_info(cls, soup, link): |
| 563 |
|
"""Get information about a particular comics.""" |
| 564 |
|
imgs = soup.find('div', id='comic').find_all('img') |
| 565 |
|
post = soup.find('div', class_='post-content') |
| 566 |
|
author = post.find("span", class_="post-author").find("a").string |
| 567 |
|
title = post.find('h2', class_='post-title').string |
| 568 |
|
date_str = post.find('span', class_='post-date').string |
| 569 |
|
day = string_to_date(date_str, "%B %d, %Y") |
| 570 |
|
assert imgs |
| 571 |
|
assert all(i['alt'] == i['title'] for i in imgs) |
| 572 |
|
assert all(i['alt'] in (title, "") for i in imgs) |
|
@@ 752-777 (lines=26) @@
|
| 749 |
|
imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive') |
| 750 |
|
return { |
| 751 |
|
'month': month, |
| 752 |
|
'year': year, |
| 753 |
|
'day': day, |
| 754 |
|
'img': [i['src'] for i in imgs], |
| 755 |
|
} |
| 756 |
|
|
| 757 |
|
|
| 758 |
|
class Dilbert(GenericNavigableComic): |
| 759 |
|
"""Class to retrieve Dilbert comics.""" |
| 760 |
|
# Also on http://www.gocomics.com/dilbert-classics |
| 761 |
|
name = 'dilbert' |
| 762 |
|
long_name = 'Dilbert' |
| 763 |
|
url = 'http://dilbert.com' |
| 764 |
|
get_url_from_link = join_cls_url_to_href |
| 765 |
|
get_first_comic_link = simulate_first_link |
| 766 |
|
first_url = 'http://dilbert.com/strip/1989-04-16' |
| 767 |
|
|
| 768 |
|
@classmethod |
| 769 |
|
def get_navi_link(cls, last_soup, next_): |
| 770 |
|
"""Get link to next or previous comic.""" |
| 771 |
|
link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left') |
| 772 |
|
return link.find('a') if link else None |
| 773 |
|
|
| 774 |
|
@classmethod |
| 775 |
|
def get_comic_info(cls, soup, link): |
| 776 |
|
"""Get information about a particular comics.""" |
| 777 |
|
title = soup.find('meta', property='og:title')['content'] |
| 778 |
|
imgs = soup.find_all('meta', property='og:image') |
| 779 |
|
desc = soup.find('meta', property='og:description')['content'] |
| 780 |
|
date_str = soup.find('meta', property='article:publish_date')['content'] |