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