|
@@ 2375-2394 (lines=20) @@
|
| 2372 |
|
return link |
| 2373 |
|
return None |
| 2374 |
|
|
| 2375 |
|
@classmethod |
| 2376 |
|
def get_comic_info(cls, soup, link): |
| 2377 |
|
"""Get information about a particular comics.""" |
| 2378 |
|
title = soup.find('meta', attrs={'name': 'description'})["content"] |
| 2379 |
|
description = soup.find('div', itemprop='articleBody').text |
| 2380 |
|
author = soup.find('span', itemprop='author copyrightHolder').string |
| 2381 |
|
imgs = soup.find_all('img', itemprop='image') |
| 2382 |
|
assert all(i['title'] == i['alt'] for i in imgs) |
| 2383 |
|
alt = imgs[0]['alt'] if imgs else "" |
| 2384 |
|
date_str = soup.find('time', itemprop='datePublished')["datetime"] |
| 2385 |
|
day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S") |
| 2386 |
|
return { |
| 2387 |
|
'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs], |
| 2388 |
|
'month': day.month, |
| 2389 |
|
'year': day.year, |
| 2390 |
|
'day': day.day, |
| 2391 |
|
'author': author, |
| 2392 |
|
'title': title, |
| 2393 |
|
'alt': alt, |
| 2394 |
|
'description': description, |
| 2395 |
|
} |
| 2396 |
|
|
| 2397 |
|
|
|
@@ 1168-1187 (lines=20) @@
|
| 1165 |
|
get_first_comic_link = get_a_comicnavbase_comicnavfirst |
| 1166 |
|
get_navi_link = get_link_rel_next |
| 1167 |
|
|
| 1168 |
|
@classmethod |
| 1169 |
|
def get_comic_info(cls, soup, link): |
| 1170 |
|
"""Get information about a particular comics.""" |
| 1171 |
|
short_url = soup.find('link', rel='shortlink')['href'] |
| 1172 |
|
date_str = soup.find('div', class_='entry-meta').contents[0].strip() |
| 1173 |
|
day = string_to_date(date_str, "%B %d, %Y") |
| 1174 |
|
imgs = soup.find('div', id='comic').find_all('img') |
| 1175 |
|
if imgs: |
| 1176 |
|
img = imgs[0] |
| 1177 |
|
title = img['alt'] |
| 1178 |
|
assert img['title'] == title |
| 1179 |
|
else: |
| 1180 |
|
title = "" |
| 1181 |
|
return { |
| 1182 |
|
'short_url': short_url, |
| 1183 |
|
'title': title, |
| 1184 |
|
'month': day.month, |
| 1185 |
|
'year': day.year, |
| 1186 |
|
'day': day.day, |
| 1187 |
|
'img': [convert_iri_to_plain_ascii_uri(i['src']) for i in imgs], |
| 1188 |
|
} |
| 1189 |
|
|
| 1190 |
|
|