Open cccchar1es opened 1 year ago
My request is fine.
Hey @cccchar1es! The code snippet above seems incomplete - how are your initializing the gis
variable? Have you defined the proper API variables as well?
Also, what is the HTTP Error you're getting? The error message doesn't say anything except the error class
HttpError Traceback (most recent call last) Cell In[24], line 12 5 7 _search_params = { 8 'q': 'puppies', 9 'num': 1, 10 } ---> 12 gis.search(search_params=_search_params, path_to_dir='/Users/shiqianghan/Downloads')
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/google_images_search/fetch_resize_save.py:151, in FetchResizeSave.search(self, search_params, path_to_dir, width, height, custom_image_name, cache_discovery) 148 self._search_params['start'] = start 149 self._search_params['num'] = num --> 151 self._search_images(*self._get_data()) 153 if len(self._search_result) >= self._number_of_images \ 154 or self.zero_return: 155 break
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/google_images_search/fetch_resize_save.py:178, in FetchResizeSave._search_images(self, search_params, path_to_dir, width, height, _custom_image_name, cache_discovery) 176 i = 0 177 threads = [] --> 178 for url, referrer_url in self._google_custom_search.search( 179 search_params, cache_discovery 180 ): 181 # initialise image object 182 image = GSImage(self) 183 image.url = url
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/google_images_search/google_api.py:83, in GoogleCustomSearch.search(self, params, cache_discovery) 75 """Search for images and returns 76 them using generator object 77 :param params: search params 78 :param cache_discovery whether or not to cache the discovery doc 79 :return: image list 80 """ 82 search_params = self._search_params(params) ---> 83 res = self._query_google_api(search_params, cache_discovery) 85 results = res.get('items', []) 86 if not results:
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/google_images_search/google_api.py:49, in GoogleCustomSearch._query_google_api(self, search_params, cache_discovery) 42 if not self._google_build: 43 self._google_build = discovery.build( 44 "customsearch", "v1", 45 developerKey=self._developer_key, 46 cache_discovery=cache_discovery) 48 return self._google_build.cse().list( ---> 49 cx=self._custom_search_cx, **search_params).execute()
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/googleapiclient/_helpers.py:130, in positional..positional_decorator..positional_wrapper(*args, *kwargs) 128 elif positional_parameters_enforcement == POSITIONAL_WARNING: 129 logger.warning(message) --> 130 return wrapped(args, **kwargs)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/googleapiclient/http.py:938, in HttpRequest.execute(self, http, num_retries) 936 callback(resp) 937 if resp.status >= 300: --> 938 raise HttpError(resp, content, uri=self.uri) 939 return self.postproc(resp, content)
HttpError: