Esempio n. 1
0
    def __init__(self,
                 client,
                 start=DEFAULT_START,
                 end=DEFAULT_END,
                 num=DEFAULT_num):
        # serp api client
        self.client = client
        # range
        self.start = start
        self.end = end
        self.num = num

        # use value from the client
        if self.start == DEFAULT_START:
            if 'start' in self.client.params_dict:
                self.start = self.client.params_dict['start']
        if self.end == DEFAULT_END:
            if 'end' in self.client.params_dict:
                self.end = self.client.params_dict['end']
        if self.num == DEFAULT_num:
            if 'num' in self.client.params_dict:
                self.num = self.client.params_dict['num']

        # basic check
        if self.start > self.end:
            raise SerpApiClientException(
                "start: {} must be less than end: {}".format(
                    self.start, self.end))
        if (self.start + self.num) > self.end:
            raise SerpApiClientException(
                "start + num: {} + {} must be less than end: {}".format(
                    self.start, self.num, self.end))
Esempio n. 2
0
 def construct_url(self, path="/search"):
     self.params_dict['source'] = 'python'
     if self.SERP_API_KEY:
         self.params_dict['serp_api_key'] = self.SERP_API_KEY
     if self.engine:
         if not 'engine' in self.params_dict:
             self.params_dict['engine'] = self.engine
     if not 'engine' in self.params_dict:
         raise SerpApiClientException(
             "engine must be defined in params_dict or engine")
     return self.BACKEND + path, self.params_dict
Esempio n. 3
0
 def get_location(self, q, limit=5):
     raise SerpApiClientException(
         "location is not supported by Yandex search engine at this time")
 def get_location(self, q, limit=5):
     raise SerpApiClientException(
         "location is not supported by youtube search engine")
Esempio n. 5
0
 def get_location(self, q, limit=5):
     raise SerpApiClientException(
         "location is not supported by Google scholar search engine")