class AlchemyKeyExtractor(BaseKeywordExtractor): def __init__(self, api_key): self.api_key = api_key self.alchemy_api = AlchemyAPI() self.alchemy_api.setAPIKey(self.api_key) def _fetch_url(self, url): try: result = self.alchemy_api.URLGetRankedKeywords(url) except Exception, e: return {'errorCode': 404, 'errors': str(e)} return result
class AlchemyLangDetector(BaseDetector): def __init__(self, api_key): self.api_key = api_key self.alchemy_api = AlchemyAPI() self.alchemy_api.setAPIKey(self.api_key) def _fetch_url(self, url): try: result = self.alchemy_api.URLGetLanguage(url) except Exception, e: return {'errorCode': 404, 'errors': str(e)} return result
def __init__(self, api_key): self.api_key = api_key self.alchemy_api = AlchemyAPI() self.alchemy_api.setAPIKey(self.api_key)