|
@@ 1309-1335 (lines=27) @@
|
| 1306 |
|
} |
| 1307 |
|
|
| 1308 |
|
|
| 1309 |
|
class ButterSafe(GenericListableComic): |
| 1310 |
|
"""Class to retrieve Butter Safe comics.""" |
| 1311 |
|
name = 'butter' |
| 1312 |
|
long_name = 'ButterSafe' |
| 1313 |
|
url = 'http://buttersafe.com' |
| 1314 |
|
get_url_from_archive_element = get_href |
| 1315 |
|
comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
| 1316 |
|
|
| 1317 |
|
@classmethod |
| 1318 |
|
def get_archive_elements(cls): |
| 1319 |
|
archive_url = urljoin_wrapper(cls.url, 'archive/') |
| 1320 |
|
return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
| 1321 |
|
|
| 1322 |
|
@classmethod |
| 1323 |
|
def get_comic_info(cls, soup, link): |
| 1324 |
|
"""Get information about a particular comics.""" |
| 1325 |
|
url = cls.get_url_from_archive_element(link) |
| 1326 |
|
title = link.string |
| 1327 |
|
year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
| 1328 |
|
img = soup.find('div', id='comic').find('img') |
| 1329 |
|
assert img['alt'] == title |
| 1330 |
|
return { |
| 1331 |
|
'title': title, |
| 1332 |
|
'day': day, |
| 1333 |
|
'month': month, |
| 1334 |
|
'year': year, |
| 1335 |
|
'img': [img['src']], |
| 1336 |
|
} |
| 1337 |
|
|
| 1338 |
|
|
|
@@ 1374-1395 (lines=22) @@
|
| 1371 |
|
last_date = comic_date |
| 1372 |
|
|
| 1373 |
|
|
| 1374 |
|
class AbstruseGoose(GenericListableComic): |
| 1375 |
|
"""Class to retrieve AbstruseGoose Comics.""" |
| 1376 |
|
name = 'abstruse' |
| 1377 |
|
long_name = 'Abstruse Goose' |
| 1378 |
|
url = 'http://abstrusegoose.com' |
| 1379 |
|
get_url_from_archive_element = get_href |
| 1380 |
|
comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
| 1381 |
|
comic_img_re = re.compile('^%s/strips/.*' % url) |
| 1382 |
|
|
| 1383 |
|
@classmethod |
| 1384 |
|
def get_archive_elements(cls): |
| 1385 |
|
archive_url = urljoin_wrapper(cls.url, 'archive') |
| 1386 |
|
return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
| 1387 |
|
|
| 1388 |
|
@classmethod |
| 1389 |
|
def get_comic_info(cls, soup, archive_elt): |
| 1390 |
|
comic_url = cls.get_url_from_archive_element(archive_elt) |
| 1391 |
|
num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
| 1392 |
|
return { |
| 1393 |
|
'num': num, |
| 1394 |
|
'title': archive_elt.string, |
| 1395 |
|
'img': [soup.find('img', src=cls.comic_img_re)['src']] |
| 1396 |
|
} |
| 1397 |
|
|
| 1398 |
|
|