@@ 1407-1433 (lines=27) @@ | ||
1404 | } |
|
1405 | ||
1406 | ||
1407 | class ButterSafe(GenericListableComic): |
|
1408 | """Class to retrieve Butter Safe comics.""" |
|
1409 | name = 'butter' |
|
1410 | long_name = 'ButterSafe' |
|
1411 | url = 'http://buttersafe.com' |
|
1412 | get_url_from_archive_element = get_href |
|
1413 | comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
|
1414 | ||
1415 | @classmethod |
|
1416 | def get_archive_elements(cls): |
|
1417 | archive_url = urljoin_wrapper(cls.url, 'archive/') |
|
1418 | return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
|
1419 | ||
1420 | @classmethod |
|
1421 | def get_comic_info(cls, soup, link): |
|
1422 | """Get information about a particular comics.""" |
|
1423 | url = cls.get_url_from_archive_element(link) |
|
1424 | title = link.string |
|
1425 | year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
|
1426 | img = soup.find('div', id='comic').find('img') |
|
1427 | assert img['alt'] == title |
|
1428 | return { |
|
1429 | 'title': title, |
|
1430 | 'day': day, |
|
1431 | 'month': month, |
|
1432 | 'year': year, |
|
1433 | 'img': [img['src']], |
|
1434 | } |
|
1435 | ||
1436 | ||
@@ 1473-1495 (lines=23) @@ | ||
1470 | last_date = comic_date |
|
1471 | ||
1472 | ||
1473 | class AbstruseGoose(GenericListableComic): |
|
1474 | """Class to retrieve AbstruseGoose Comics.""" |
|
1475 | name = 'abstruse' |
|
1476 | long_name = 'Abstruse Goose' |
|
1477 | url = 'http://abstrusegoose.com' |
|
1478 | get_url_from_archive_element = get_href |
|
1479 | comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
|
1480 | comic_img_re = re.compile('^%s/strips/.*' % url) |
|
1481 | ||
1482 | @classmethod |
|
1483 | def get_archive_elements(cls): |
|
1484 | archive_url = urljoin_wrapper(cls.url, 'archive') |
|
1485 | return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
|
1486 | ||
1487 | @classmethod |
|
1488 | def get_comic_info(cls, soup, archive_elt): |
|
1489 | comic_url = cls.get_url_from_archive_element(archive_elt) |
|
1490 | num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
|
1491 | imgs = soup.find_all('img', src=cls.comic_img_re) |
|
1492 | return { |
|
1493 | 'num': num, |
|
1494 | 'title': archive_elt.string, |
|
1495 | 'img': [i['src'] for i in imgs], |
|
1496 | } |
|
1497 | ||
1498 | ||
@@ 2374-2398 (lines=25) @@ | ||
2371 | } |
|
2372 | ||
2373 | ||
2374 | class JuliasDrawings(GenericListableComic): |
|
2375 | """Class to retrieve Julia's Drawings.""" |
|
2376 | name = 'julia' |
|
2377 | long_name = "Julia's Drawings" |
|
2378 | url = 'https://drawings.jvns.ca' |
|
2379 | get_url_from_archive_element = get_href |
|
2380 | ||
2381 | @classmethod |
|
2382 | def get_archive_elements(cls): |
|
2383 | div = get_soup_at_url(cls.url).find('div', class_='drawings') |
|
2384 | return reversed(div.find_all('a')) |
|
2385 | ||
2386 | @classmethod |
|
2387 | def get_comic_info(cls, soup, archive_elt): |
|
2388 | """Get information about a particular comics.""" |
|
2389 | date_str = soup.find('meta', property='og:article:published_time')['content'][:10] |
|
2390 | day = string_to_date(date_str, "%Y-%m-%d") |
|
2391 | title = soup.find('h3', class_='p-post-title').string |
|
2392 | imgs = soup.find('section', class_='post-content').find_all('img') |
|
2393 | return { |
|
2394 | 'title': title, |
|
2395 | 'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs], |
|
2396 | 'month': day.month, |
|
2397 | 'year': day.year, |
|
2398 | 'day': day.day, |
|
2399 | } |
|
2400 | ||
2401 |