@@ 1327-1353 (lines=27) @@ | ||
1324 | } |
|
1325 | ||
1326 | ||
1327 | class ButterSafe(GenericListableComic): |
|
1328 | """Class to retrieve Butter Safe comics.""" |
|
1329 | name = 'butter' |
|
1330 | long_name = 'ButterSafe' |
|
1331 | url = 'http://buttersafe.com' |
|
1332 | get_url_from_archive_element = get_href |
|
1333 | comic_link_re = re.compile('^{0!s}/([0-9]*)/([0-9]*)/([0-9]*)/.*'.format(url)) |
|
1334 | ||
1335 | @classmethod |
|
1336 | def get_archive_elements(cls): |
|
1337 | archive_url = urljoin_wrapper(cls.url, 'archive/') |
|
1338 | return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
|
1339 | ||
1340 | @classmethod |
|
1341 | def get_comic_info(cls, soup, link): |
|
1342 | """Get information about a particular comics.""" |
|
1343 | url = cls.get_url_from_archive_element(link) |
|
1344 | title = link.string |
|
1345 | year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
|
1346 | img = soup.find('div', id='comic').find('img') |
|
1347 | assert img['alt'] == title |
|
1348 | return { |
|
1349 | 'title': title, |
|
1350 | 'day': day, |
|
1351 | 'month': month, |
|
1352 | 'year': year, |
|
1353 | 'img': [img['src']], |
|
1354 | } |
|
1355 | ||
1356 | ||
@@ 1393-1414 (lines=22) @@ | ||
1390 | last_date = comic_date |
|
1391 | ||
1392 | ||
1393 | class AbstruseGoose(GenericListableComic): |
|
1394 | """Class to retrieve AbstruseGoose Comics.""" |
|
1395 | name = 'abstruse' |
|
1396 | long_name = 'Abstruse Goose' |
|
1397 | url = 'http://abstrusegoose.com' |
|
1398 | get_url_from_archive_element = get_href |
|
1399 | comic_url_re = re.compile('^{0!s}/([0-9]*)$'.format(url)) |
|
1400 | comic_img_re = re.compile('^{0!s}/strips/.*'.format(url)) |
|
1401 | ||
1402 | @classmethod |
|
1403 | def get_archive_elements(cls): |
|
1404 | archive_url = urljoin_wrapper(cls.url, 'archive') |
|
1405 | return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
|
1406 | ||
1407 | @classmethod |
|
1408 | def get_comic_info(cls, soup, archive_elt): |
|
1409 | comic_url = cls.get_url_from_archive_element(archive_elt) |
|
1410 | num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
|
1411 | return { |
|
1412 | 'num': num, |
|
1413 | 'title': archive_elt.string, |
|
1414 | 'img': [soup.find('img', src=cls.comic_img_re)['src']] |
|
1415 | } |
|
1416 | ||
1417 |