@@ 1430-1456 (lines=27) @@ | ||
1427 | } |
|
1428 | ||
1429 | ||
1430 | class ButterSafe(GenericListableComic): |
|
1431 | """Class to retrieve Butter Safe comics.""" |
|
1432 | name = 'butter' |
|
1433 | long_name = 'ButterSafe' |
|
1434 | url = 'http://buttersafe.com' |
|
1435 | get_url_from_archive_element = get_href |
|
1436 | comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
|
1437 | ||
1438 | @classmethod |
|
1439 | def get_archive_elements(cls): |
|
1440 | archive_url = urljoin_wrapper(cls.url, 'archive/') |
|
1441 | return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
|
1442 | ||
1443 | @classmethod |
|
1444 | def get_comic_info(cls, soup, link): |
|
1445 | """Get information about a particular comics.""" |
|
1446 | url = cls.get_url_from_archive_element(link) |
|
1447 | title = link.string |
|
1448 | year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
|
1449 | img = soup.find('div', id='comic').find('img') |
|
1450 | assert img['alt'] == title |
|
1451 | return { |
|
1452 | 'title': title, |
|
1453 | 'day': day, |
|
1454 | 'month': month, |
|
1455 | 'year': year, |
|
1456 | 'img': [img['src']], |
|
1457 | } |
|
1458 | ||
1459 | ||
@@ 2426-2450 (lines=25) @@ | ||
2423 | } |
|
2424 | ||
2425 | ||
2426 | class JuliasDrawings(GenericListableComic): |
|
2427 | """Class to retrieve Julia's Drawings.""" |
|
2428 | name = 'julia' |
|
2429 | long_name = "Julia's Drawings" |
|
2430 | url = 'https://drawings.jvns.ca' |
|
2431 | get_url_from_archive_element = get_href |
|
2432 | ||
2433 | @classmethod |
|
2434 | def get_archive_elements(cls): |
|
2435 | div = get_soup_at_url(cls.url).find('div', class_='drawings') |
|
2436 | return reversed(div.find_all('a')) |
|
2437 | ||
2438 | @classmethod |
|
2439 | def get_comic_info(cls, soup, archive_elt): |
|
2440 | """Get information about a particular comics.""" |
|
2441 | date_str = soup.find('meta', property='og:article:published_time')['content'][:10] |
|
2442 | day = string_to_date(date_str, "%Y-%m-%d") |
|
2443 | title = soup.find('h3', class_='p-post-title').string |
|
2444 | imgs = soup.find('section', class_='post-content').find_all('img') |
|
2445 | return { |
|
2446 | 'title': title, |
|
2447 | 'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs], |
|
2448 | 'month': day.month, |
|
2449 | 'year': day.year, |
|
2450 | 'day': day.day, |
|
2451 | } |
|
2452 | ||
2453 | ||
@@ 1496-1518 (lines=23) @@ | ||
1493 | last_date = comic_date |
|
1494 | ||
1495 | ||
1496 | class AbstruseGoose(GenericListableComic): |
|
1497 | """Class to retrieve AbstruseGoose Comics.""" |
|
1498 | name = 'abstruse' |
|
1499 | long_name = 'Abstruse Goose' |
|
1500 | url = 'http://abstrusegoose.com' |
|
1501 | get_url_from_archive_element = get_href |
|
1502 | comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
|
1503 | comic_img_re = re.compile('^%s/strips/.*' % url) |
|
1504 | ||
1505 | @classmethod |
|
1506 | def get_archive_elements(cls): |
|
1507 | archive_url = urljoin_wrapper(cls.url, 'archive') |
|
1508 | return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
|
1509 | ||
1510 | @classmethod |
|
1511 | def get_comic_info(cls, soup, archive_elt): |
|
1512 | comic_url = cls.get_url_from_archive_element(archive_elt) |
|
1513 | num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
|
1514 | imgs = soup.find_all('img', src=cls.comic_img_re) |
|
1515 | return { |
|
1516 | 'num': num, |
|
1517 | 'title': archive_elt.string, |
|
1518 | 'img': [i['src'] for i in imgs], |
|
1519 | } |
|
1520 | ||
1521 |