@@ 2930-2950 (lines=21) @@ | ||
2927 | li = last_soup.find('li', class_='prev' if next_ else 'next') |
|
2928 | return li.find('a') if li else None |
|
2929 | ||
2930 | @classmethod |
|
2931 | def get_comic_info(cls, soup, link): |
|
2932 | """Get information about a particular comics.""" |
|
2933 | title = soup.find('meta', property='og:title')['content'] |
|
2934 | desc = soup.find('meta', property='og:description')['content'] |
|
2935 | date_str = soup.find('time', class_='published')['datetime'] |
|
2936 | day = string_to_date(date_str, "%Y-%m-%d") |
|
2937 | author = soup.find('a', rel='author').string |
|
2938 | div_content = soup.find('div', class_="body entry-content") |
|
2939 | imgs = div_content.find_all('img') |
|
2940 | imgs = [i for i in imgs if i.get('src') is not None] |
|
2941 | alt = imgs[0]['alt'] |
|
2942 | return { |
|
2943 | 'title': title, |
|
2944 | 'alt': alt, |
|
2945 | 'description': desc, |
|
2946 | 'author': author, |
|
2947 | 'day': day.day, |
|
2948 | 'month': day.month, |
|
2949 | 'year': day.year, |
|
2950 | 'img': [i['src'] for i in imgs], |
|
2951 | } |
|
2952 | ||
2953 | ||
@@ 2818-2838 (lines=21) @@ | ||
2815 | get_first_comic_link = get_a_navi_navifirst |
|
2816 | get_navi_link = get_link_rel_next |
|
2817 | ||
2818 | @classmethod |
|
2819 | def get_comic_info(cls, soup, link): |
|
2820 | """Get information about a particular comics.""" |
|
2821 | title = soup.find('h2', class_='post-title').string |
|
2822 | short_url = soup.find('link', rel='shortlink')['href'] |
|
2823 | short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url) |
|
2824 | num = int(short_url_re.match(short_url).groups()[0]) |
|
2825 | imgs = soup.find('div', id='comic').find_all('img') |
|
2826 | alt = imgs[0]['title'] |
|
2827 | assert all(i['alt'] == i['title'] == alt for i in imgs) |
|
2828 | date_str = soup.find('span', class_='post-date').string |
|
2829 | day = string_to_date(date_str, "%d/%m/%Y") |
|
2830 | return { |
|
2831 | 'short_url': short_url, |
|
2832 | 'num': num, |
|
2833 | 'img': [i['src'] for i in imgs], |
|
2834 | 'month': day.month, |
|
2835 | 'year': day.year, |
|
2836 | 'day': day.day, |
|
2837 | 'alt': alt, |
|
2838 | 'title': title, |
|
2839 | } |
|
2840 | ||
2841 | ||
@@ 2335-2354 (lines=20) @@ | ||
2332 | return link |
|
2333 | return None |
|
2334 | ||
2335 | @classmethod |
|
2336 | def get_comic_info(cls, soup, link): |
|
2337 | """Get information about a particular comics.""" |
|
2338 | title = soup.find('meta', attrs={'name': 'description'})["content"] |
|
2339 | description = soup.find('div', itemprop='articleBody').text |
|
2340 | author = soup.find('span', itemprop='author copyrightHolder').string |
|
2341 | imgs = soup.find_all('img', itemprop='image') |
|
2342 | assert all(i['title'] == i['alt'] for i in imgs) |
|
2343 | alt = imgs[0]['alt'] if imgs else "" |
|
2344 | date_str = soup.find('time', itemprop='datePublished')["datetime"] |
|
2345 | day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S") |
|
2346 | return { |
|
2347 | 'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs], |
|
2348 | 'month': day.month, |
|
2349 | 'year': day.year, |
|
2350 | 'day': day.day, |
|
2351 | 'author': author, |
|
2352 | 'title': title, |
|
2353 | 'alt': alt, |
|
2354 | 'description': description, |
|
2355 | } |
|
2356 | ||
2357 |