|
@@ 829-847 (lines=19) @@
|
| 826 |
|
link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left') |
| 827 |
|
return link.find('a') if link else None |
| 828 |
|
|
| 829 |
|
@classmethod |
| 830 |
|
def get_comic_info(cls, soup, link): |
| 831 |
|
"""Get information about a particular comics.""" |
| 832 |
|
title = soup.find('meta', property='og:title')['content'] |
| 833 |
|
imgs = soup.find_all('meta', property='og:image') |
| 834 |
|
desc = soup.find('meta', property='og:description')['content'] |
| 835 |
|
date_str = soup.find('meta', property='article:publish_date')['content'] |
| 836 |
|
day = string_to_date(date_str, "%B %d, %Y") |
| 837 |
|
author = soup.find('meta', property='article:author')['content'] |
| 838 |
|
tags = soup.find('meta', property='article:tag')['content'] |
| 839 |
|
return { |
| 840 |
|
'title': title, |
| 841 |
|
'description': desc, |
| 842 |
|
'img': [i['content'] for i in imgs], |
| 843 |
|
'author': author, |
| 844 |
|
'tags': tags, |
| 845 |
|
'day': day.day, |
| 846 |
|
'month': day.month, |
| 847 |
|
'year': day.year |
| 848 |
|
} |
| 849 |
|
|
| 850 |
|
|
|
@@ 3038-3058 (lines=21) @@
|
| 3035 |
|
li = last_soup.find('li', class_='prev' if next_ else 'next') |
| 3036 |
|
return li.find('a') if li else None |
| 3037 |
|
|
| 3038 |
|
@classmethod |
| 3039 |
|
def get_comic_info(cls, soup, link): |
| 3040 |
|
"""Get information about a particular comics.""" |
| 3041 |
|
title = soup.find('meta', property='og:title')['content'] |
| 3042 |
|
desc = soup.find('meta', property='og:description')['content'] |
| 3043 |
|
date_str = soup.find('time', class_='published')['datetime'] |
| 3044 |
|
day = string_to_date(date_str, "%Y-%m-%d") |
| 3045 |
|
author = soup.find('a', rel='author').string |
| 3046 |
|
div_content = soup.find('div', class_="body entry-content") |
| 3047 |
|
imgs = div_content.find_all('img') |
| 3048 |
|
imgs = [i for i in imgs if i.get('src') is not None] |
| 3049 |
|
alt = imgs[0]['alt'] |
| 3050 |
|
return { |
| 3051 |
|
'title': title, |
| 3052 |
|
'alt': alt, |
| 3053 |
|
'description': desc, |
| 3054 |
|
'author': author, |
| 3055 |
|
'day': day.day, |
| 3056 |
|
'month': day.month, |
| 3057 |
|
'year': day.year, |
| 3058 |
|
'img': [i['src'] for i in imgs], |
| 3059 |
|
} |
| 3060 |
|
|
| 3061 |
|
|