|
@@ 381-402 (lines=22) @@
|
| 378 |
|
} |
| 379 |
|
|
| 380 |
|
|
| 381 |
|
class GenericLeMondeBlog(GenericNavigableComic): |
| 382 |
|
"""Generic class to retrieve comics from Le Monde blogs.""" |
| 383 |
|
_categories = ('LEMONDE', 'FRANCAIS') |
| 384 |
|
get_navi_link = get_link_rel_next |
| 385 |
|
get_first_comic_link = simulate_first_link |
| 386 |
|
first_url = NotImplemented |
| 387 |
|
|
| 388 |
|
@classmethod |
| 389 |
|
def get_comic_info(cls, soup, link): |
| 390 |
|
"""Get information about a particular comics.""" |
| 391 |
|
url2 = soup.find('link', rel='shortlink')['href'] |
| 392 |
|
title = soup.find('meta', property='og:title')['content'] |
| 393 |
|
date_str = soup.find("span", class_="entry-date").string |
| 394 |
|
day = string_to_date(date_str, "%d %B %Y", "fr_FR.utf8") |
| 395 |
|
imgs = soup.find_all('meta', property='og:image') |
| 396 |
|
return { |
| 397 |
|
'title': title, |
| 398 |
|
'url2': url2, |
| 399 |
|
'img': [convert_iri_to_plain_ascii_uri(i['content']) for i in imgs], |
| 400 |
|
'month': day.month, |
| 401 |
|
'year': day.year, |
| 402 |
|
'day': day.day, |
| 403 |
|
} |
| 404 |
|
|
| 405 |
|
|
|
@@ 952-977 (lines=26) @@
|
| 949 |
|
} |
| 950 |
|
|
| 951 |
|
|
| 952 |
|
class MyExtraLife(GenericNavigableComic): |
| 953 |
|
"""Class to retrieve My Extra Life comics.""" |
| 954 |
|
name = 'extralife' |
| 955 |
|
long_name = 'My Extra Life' |
| 956 |
|
url = 'http://www.myextralife.com' |
| 957 |
|
get_navi_link = get_link_rel_next |
| 958 |
|
|
| 959 |
|
@classmethod |
| 960 |
|
def get_first_comic_link(cls): |
| 961 |
|
"""Get link to first comics.""" |
| 962 |
|
return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link') |
| 963 |
|
|
| 964 |
|
@classmethod |
| 965 |
|
def get_comic_info(cls, soup, link): |
| 966 |
|
"""Get information about a particular comics.""" |
| 967 |
|
title = soup.find("h1", class_="comic_title").string |
| 968 |
|
date_str = soup.find("span", class_="comic_date").string |
| 969 |
|
day = string_to_date(date_str, "%B %d, %Y") |
| 970 |
|
imgs = soup.find_all("img", class_="comic") |
| 971 |
|
assert all(i['alt'] == i['title'] == title for i in imgs) |
| 972 |
|
return { |
| 973 |
|
'title': title, |
| 974 |
|
'img': [i['src'] for i in imgs if i["src"]], |
| 975 |
|
'day': day.day, |
| 976 |
|
'month': day.month, |
| 977 |
|
'year': day.year |
| 978 |
|
} |
| 979 |
|
|
| 980 |
|
|