示例#1
0
class YandexEngine(EngineBase):
    """Yandex.
       * need init with a username and api_key
    """
    name = "yandex"
    url = "http://www.yandex.com/"

    DEFAULT_WEIGHT = 0.3
    RESULT_MAX_LIMIT = 10

    def _post_config(self):
        self.yasearch = YaSearch(self.username, self.api_key)

    def _send_request(self, query, **kwargs):
        lang = kwargs.pop("lang", self.DEFAULT_LANG)
        return self.yasearch.search(query, **kwargs)

    def _clean_raw_data(self, raw_data):
        if raw_data.error is None:
            results = [
                YandexResultItem.new(item, source=self)
                for item in raw_data.items
            ]
            return results
        else:
            return []
示例#2
0
class YandexEngine(EngineBase):
    """Yandex.
       * need init with a username and api_key
    """
    name = "yandex"
    url = "http://www.yandex.com/"

    DEFAULT_WEIGHT = 0.3
    RESULT_MAX_LIMIT = 10

    def _post_config(self):
        self.yasearch = YaSearch(self.username, self.api_key)

    def _send_request(self, query, **kwargs):
        lang = kwargs.pop("lang", self.DEFAULT_LANG)
        return self.yasearch.search(query, **kwargs)

    def _clean_raw_data(self, raw_data):
        if raw_data.error is None:
            results = [YandexResultItem.new(item, source=self) for item in raw_data.items]
            return results
        else:
            return []
示例#3
0
 def _post_config(self):
     self.yasearch = YaSearch(self.username, self.api_key)
示例#4
0
 def _post_config(self):
     self.yasearch = YaSearch(self.username, self.api_key)