@@ 1361-1387 (lines=27) @@ | ||
1358 | } |
|
1359 | ||
1360 | ||
1361 | class ButterSafe(GenericListableComic): |
|
1362 | """Class to retrieve Butter Safe comics.""" |
|
1363 | name = 'butter' |
|
1364 | long_name = 'ButterSafe' |
|
1365 | url = 'http://buttersafe.com' |
|
1366 | get_url_from_archive_element = get_href |
|
1367 | comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
|
1368 | ||
1369 | @classmethod |
|
1370 | def get_archive_elements(cls): |
|
1371 | archive_url = urljoin_wrapper(cls.url, 'archive/') |
|
1372 | return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
|
1373 | ||
1374 | @classmethod |
|
1375 | def get_comic_info(cls, soup, link): |
|
1376 | """Get information about a particular comics.""" |
|
1377 | url = cls.get_url_from_archive_element(link) |
|
1378 | title = link.string |
|
1379 | year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
|
1380 | img = soup.find('div', id='comic').find('img') |
|
1381 | assert img['alt'] == title |
|
1382 | return { |
|
1383 | 'title': title, |
|
1384 | 'day': day, |
|
1385 | 'month': month, |
|
1386 | 'year': year, |
|
1387 | 'img': [img['src']], |
|
1388 | } |
|
1389 | ||
1390 | ||
@@ 1427-1448 (lines=22) @@ | ||
1424 | last_date = comic_date |
|
1425 | ||
1426 | ||
1427 | class AbstruseGoose(GenericListableComic): |
|
1428 | """Class to retrieve AbstruseGoose Comics.""" |
|
1429 | name = 'abstruse' |
|
1430 | long_name = 'Abstruse Goose' |
|
1431 | url = 'http://abstrusegoose.com' |
|
1432 | get_url_from_archive_element = get_href |
|
1433 | comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
|
1434 | comic_img_re = re.compile('^%s/strips/.*' % url) |
|
1435 | ||
1436 | @classmethod |
|
1437 | def get_archive_elements(cls): |
|
1438 | archive_url = urljoin_wrapper(cls.url, 'archive') |
|
1439 | return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
|
1440 | ||
1441 | @classmethod |
|
1442 | def get_comic_info(cls, soup, archive_elt): |
|
1443 | comic_url = cls.get_url_from_archive_element(archive_elt) |
|
1444 | num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
|
1445 | return { |
|
1446 | 'num': num, |
|
1447 | 'title': archive_elt.string, |
|
1448 | 'img': [soup.find('img', src=cls.comic_img_re)['src']] |
|
1449 | } |
|
1450 | ||
1451 |