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