@@ 2479-2498 (lines=20) @@ | ||
2476 | return link |
|
2477 | return None |
|
2478 | ||
2479 | @classmethod |
|
2480 | def get_comic_info(cls, soup, link): |
|
2481 | """Get information about a particular comics.""" |
|
2482 | title = soup.find('meta', attrs={'name': 'description'})["content"] |
|
2483 | description = soup.find('div', itemprop='articleBody').text |
|
2484 | author = soup.find('span', itemprop='author copyrightHolder').string |
|
2485 | imgs = soup.find_all('img', itemprop='image') |
|
2486 | assert all(i['title'] == i['alt'] for i in imgs) |
|
2487 | alt = imgs[0]['alt'] if imgs else "" |
|
2488 | date_str = soup.find('time', itemprop='datePublished')["datetime"] |
|
2489 | day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S") |
|
2490 | return { |
|
2491 | 'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs], |
|
2492 | 'month': day.month, |
|
2493 | 'year': day.year, |
|
2494 | 'day': day.day, |
|
2495 | 'author': author, |
|
2496 | 'title': title, |
|
2497 | 'alt': alt, |
|
2498 | 'description': description, |
|
2499 | } |
|
2500 | ||
2501 | ||
@@ 1220-1239 (lines=20) @@ | ||
1217 | get_first_comic_link = get_a_comicnavbase_comicnavfirst |
|
1218 | get_navi_link = get_link_rel_next |
|
1219 | ||
1220 | @classmethod |
|
1221 | def get_comic_info(cls, soup, link): |
|
1222 | """Get information about a particular comics.""" |
|
1223 | short_url = soup.find('link', rel='shortlink')['href'] |
|
1224 | date_str = soup.find('div', class_='entry-meta').contents[0].strip() |
|
1225 | day = string_to_date(date_str, "%B %d, %Y") |
|
1226 | imgs = soup.find('div', id='comic').find_all('img') |
|
1227 | if imgs: |
|
1228 | img = imgs[0] |
|
1229 | title = img['alt'] |
|
1230 | assert img['title'] == title |
|
1231 | else: |
|
1232 | title = "" |
|
1233 | return { |
|
1234 | 'short_url': short_url, |
|
1235 | 'title': title, |
|
1236 | 'month': day.month, |
|
1237 | 'year': day.year, |
|
1238 | 'day': day.day, |
|
1239 | 'img': [convert_iri_to_plain_ascii_uri(i['src']) for i in imgs], |
|
1240 | } |
|
1241 | ||
1242 |