@@ 4241-4276 (lines=36) @@ | ||
4238 | @classmethod |
|
4239 | def get_archive_elements(cls): |
|
4240 | archive_url = 'http://www.horovitzcomics.com/comics/archive/' |
|
4241 | return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.link_re)) |
|
4242 | ||
4243 | ||
4244 | class HorovitzNew(HorovitzComics): |
|
4245 | """Class to retrieve Horovitz new comics.""" |
|
4246 | name = 'horovitznew' |
|
4247 | long_name = 'Horovitz New' |
|
4248 | link_re = re.compile('^/comics/new/([0-9]+)$') |
|
4249 | ||
4250 | ||
4251 | class HorovitzClassic(HorovitzComics): |
|
4252 | """Class to retrieve Horovitz classic comics.""" |
|
4253 | name = 'horovitzclassic' |
|
4254 | long_name = 'Horovitz Classic' |
|
4255 | link_re = re.compile('^/comics/classic/([0-9]+)$') |
|
4256 | ||
4257 | ||
4258 | class GenericGoComic(GenericNavigableComic): |
|
4259 | """Generic class to handle the logic common to comics from gocomics.com.""" |
|
4260 | _categories = ('GOCOMIC', ) |
|
4261 | ||
4262 | @classmethod |
|
4263 | def get_first_comic_link(cls): |
|
4264 | """Get link to first comics.""" |
|
4265 | return get_soup_at_url(cls.url).find('a', class_='fa btn btn-outline-default btn-circle fa-backward sm ') |
|
4266 | ||
4267 | @classmethod |
|
4268 | def get_navi_link(cls, last_soup, next_): |
|
4269 | """Get link to next or previous comic.""" |
|
4270 | PREV = 'fa btn btn-outline-default btn-circle fa-caret-left sm ' |
|
4271 | NEXT = 'fa btn btn-outline-default btn-circle fa-caret-right sm ' |
|
4272 | return last_soup.find('a', class_=NEXT if next_ else PREV) |
|
4273 | ||
4274 | @classmethod |
|
4275 | def get_url_from_link(cls, link): |
|
4276 | gocomics = 'http://www.gocomics.com' |
|
4277 | return urljoin_wrapper(gocomics, link['href']) |
|
4278 | ||
4279 | @classmethod |
|
@@ 3215-3249 (lines=35) @@ | ||
3212 | title = soup.find('meta', property='og:title')['content'] |
|
3213 | return { |
|
3214 | 'img': [i['content'] for i in imgs], |
|
3215 | 'day': day.day, |
|
3216 | 'month': day.month, |
|
3217 | 'year': day.year, |
|
3218 | 'title': title, |
|
3219 | } |
|
3220 | ||
3221 | ||
3222 | class ConsoliaComics(GenericNavigableComic): |
|
3223 | """Class to retrieve Consolia comics.""" |
|
3224 | name = 'consolia' |
|
3225 | long_name = 'consolia' |
|
3226 | url = 'https://consolia-comic.com' |
|
3227 | get_url_from_link = join_cls_url_to_href |
|
3228 | ||
3229 | @classmethod |
|
3230 | def get_first_comic_link(cls): |
|
3231 | """Get link to first comics.""" |
|
3232 | return get_soup_at_url(cls.url).find('span', class_='first').find('a') |
|
3233 | ||
3234 | @classmethod |
|
3235 | def get_navi_link(cls, last_soup, next_): |
|
3236 | """Get link to next or previous comic.""" |
|
3237 | return last_soup.find('span', class_='next' if next_ else 'prev').find('a') |
|
3238 | ||
3239 | @classmethod |
|
3240 | def get_comic_info(cls, soup, link): |
|
3241 | """Get information about a particular comics.""" |
|
3242 | title = soup.find('meta', property='og:title')['content'] |
|
3243 | date_str = soup.find('time')["datetime"] |
|
3244 | day = string_to_date(date_str, "%Y-%m-%d") |
|
3245 | imgs = soup.find('div', id='comic').find_all('img') |
|
3246 | alt = imgs[0]['title'] |
|
3247 | # article = soup.find('div', id='blag') |
|
3248 | # text = article.encode_contents() |
|
3249 | return { |
|
3250 | 'title': title, |
|
3251 | 'alt': alt, |
|
3252 | 'img': [i['src'] for i in imgs], |