@@ 2300-2319 (lines=20) @@ | ||
2297 | } |
|
2298 | ||
2299 | ||
2300 | class AnythingComic(GenericListableComic): |
|
2301 | """Class to retrieve Anything Comics.""" |
|
2302 | # Also on http://tapastic.com/series/anything |
|
2303 | name = 'anythingcomic' |
|
2304 | long_name = 'Anything Comic' |
|
2305 | url = 'http://www.anythingcomic.com' |
|
2306 | ||
2307 | @classmethod |
|
2308 | def get_archive_elements(cls): |
|
2309 | archive_url = urljoin_wrapper(cls.url, 'archive/') |
|
2310 | # The first 2 <tr>'s do not correspond to comics |
|
2311 | return get_soup_at_url(archive_url).find('table', id='chapter_table').find_all('tr')[2:] |
|
2312 | ||
2313 | @classmethod |
|
2314 | def get_url_from_archive_element(cls, tr): |
|
2315 | """Get url corresponding to an archive element.""" |
|
2316 | td_num, td_comic, td_date, _ = tr.find_all('td') |
|
2317 | link = td_comic.find('a') |
|
2318 | return urljoin_wrapper(cls.url, link['href']) |
|
2319 | ||
2320 | @classmethod |
|
2321 | def get_comic_info(cls, soup, tr): |
|
2322 | """Get information about a particular comics.""" |
|
@@ 1968-1986 (lines=19) @@ | ||
1965 | def get_comic_info(cls, soup, td): |
|
1966 | """Get information about a particular comics.""" |
|
1967 | url = cls.get_url_from_archive_element(td) |
|
1968 | title = td.find('a').string |
|
1969 | month_and_day = td.previous_sibling.string |
|
1970 | link_re = re.compile('^%s/([0-9]+)/' % cls.url) |
|
1971 | year = link_re.match(url).groups()[0] |
|
1972 | date_str = month_and_day + ' ' + year |
|
1973 | day = string_to_date(date_str, '%b %d %Y') |
|
1974 | imgs = [soup.find('div', id='comic').find('img')] |
|
1975 | assert len(imgs) == 1 |
|
1976 | assert all(i['title'] == i['alt'] == title for i in imgs) |
|
1977 | return { |
|
1978 | 'month': day.month, |
|
1979 | 'year': day.year, |
|
1980 | 'day': day.day, |
|
1981 | 'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs], |
|
1982 | 'title': title, |
|
1983 | } |
|
1984 | ||
1985 | ||
1986 | class DiscoBleach(GenericEmptyComic): # Does not work anymore |
|
1987 | """Class to retrieve Disco Bleach Comics.""" |
|
1988 | name = 'discobleach' |
|
1989 | long_name = 'Disco Bleach' |