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