@@ 2129-2145 (lines=17) @@ | ||
2126 | get_first_comic_link = get_div_navfirst_a |
|
2127 | get_navi_link = get_link_rel_next |
|
2128 | ||
2129 | @classmethod |
|
2130 | def get_comic_info(cls, soup, link): |
|
2131 | """Get information about a particular comics.""" |
|
2132 | date_str = soup.find('span', class_='post-date').string |
|
2133 | day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y") |
|
2134 | author = soup.find('span', class_='post-author').string |
|
2135 | div = soup.find('div', id='comic') |
|
2136 | imgs = div.find_all('img') if div else [] |
|
2137 | title = imgs[0]['title'] if imgs else "" |
|
2138 | assert all(i['title'] == i['alt'] == title for i in imgs) |
|
2139 | return { |
|
2140 | 'month': day.month, |
|
2141 | 'year': day.year, |
|
2142 | 'day': day.day, |
|
2143 | 'img': [i['src'] for i in imgs], |
|
2144 | 'title': title, |
|
2145 | 'author': author, |
|
2146 | } |
|
2147 | ||
2148 | ||
@@ 1029-1044 (lines=16) @@ | ||
1026 | """Get link to first comics.""" |
|
1027 | return get_soup_at_url(cls.url).find('a', rel='start') |
|
1028 | ||
1029 | @classmethod |
|
1030 | def get_comic_info(cls, soup, link): |
|
1031 | """Get information about a particular comics.""" |
|
1032 | image1 = soup.find('img', id='cc-comic') |
|
1033 | image_url1 = image1['src'] |
|
1034 | aftercomic = soup.find('div', id='aftercomic') |
|
1035 | image_url2 = aftercomic.find('img')['src'] if aftercomic else '' |
|
1036 | imgs = [image_url1] + ([image_url2] if image_url2 else []) |
|
1037 | date_str = soup.find('div', class_='cc-publishtime').contents[0] |
|
1038 | day = string_to_date(date_str, "%B %d, %Y") |
|
1039 | return { |
|
1040 | 'title': image1['title'], |
|
1041 | 'img': [convert_iri_to_plain_ascii_uri(urljoin_wrapper(cls.url, i)) for i in imgs], |
|
1042 | 'day': day.day, |
|
1043 | 'month': day.month, |
|
1044 | 'year': day.year |
|
1045 | } |
|
1046 | ||
1047 |