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