2016-11-27 01:58:25 -06:00
|
|
|
from . import yuku, pickle
|
2016-11-26 23:09:12 -06:00
|
|
|
|
2016-11-27 01:58:25 -06:00
|
|
|
scrapers = [yuku, pickle]
|
2016-11-26 23:09:12 -06:00
|
|
|
|
|
|
|
def get_scraper (name):
|
|
|
|
for scraper in scrapers:
|
|
|
|
if scraper.__name__.endswith(".{}".format(name)):
|
|
|
|
return scraper
|
|
|
|
|
|
|
|
raise Exception("Unknown scraper: {}".format(name))
|
|
|
|
|
|
|
|
def guess_scraper (url):
|
|
|
|
for scraper in scrapers:
|
2016-11-27 01:58:25 -06:00
|
|
|
if "can_scrape_url" in vars(scraper) and scraper.can_scrape_url(url):
|
2016-11-26 23:09:12 -06:00
|
|
|
return scraper
|
|
|
|
|
|
|
|
raise Exception("Unable to guess scraper for forum url: {}".format(url))
|