diff --git a/serpapi/google_search.py b/serpapi/google_search.py index bf85638..76dcd6e 100644 --- a/serpapi/google_search.py +++ b/serpapi/google_search.py @@ -4,12 +4,19 @@ class GoogleSearch(SerpApiClient): """GoogleSearch enables to search google and parse the result. ```python from serpapi import GoogleSearch - query = GoogleSearch({"q": "coffee", "location": "Austin,Texas"}) + query = GoogleSearch( + { + "q": "coffee", + "location": "Austin,Texas", + }, + timeout = 60, + ssl_verify = True, + ) data = query.get_json() ``` https://github.com/serpapi/google-search-results-python """ - def __init__(self, params_dict): - super(GoogleSearch, self).__init__(params_dict, GOOGLE_ENGINE) + def __init__(self, params_dict, timeout = 60, ssl_verify = True): + super(GoogleSearch, self).__init__(params_dict, GOOGLE_ENGINE, timeout, ssl_verify) diff --git a/serpapi/serp_api_client.py b/serpapi/serp_api_client.py index f52075f..eef4a89 100644 --- a/serpapi/serp_api_client.py +++ b/serpapi/serp_api_client.py @@ -9,12 +9,16 @@ class SerpApiClient(object): """SerpApiClient enables to query any search engines supported by SerpApi and parse the results. ```python from serpapi import GoogleSearch - search = SerpApiClient({ - "q": "Coffee", - "location": "Austin,Texas", - "engine": "google", - "api_key": "" - }) + search = SerpApiClient( + { + "q": "Coffee", + "location": "Austin,Texas", + "engine": "google", + "api_key": "", + }, + timeout = 60, + ssl_verify = True, + ) data = search.get_json() ``` @@ -24,10 +28,11 @@ class SerpApiClient(object): BACKEND = "https://serpapi.com" SERP_API_KEY = None - def __init__(self, params_dict, engine = None, timeout = 60000): + def __init__(self, params_dict, engine = None, timeout = 60, ssl_verify = True): self.params_dict = params_dict self.engine = engine self.timeout = timeout + self.ssl_verify = ssl_verify def construct_url(self, path = "/search"): self.params_dict['source'] = 'python' @@ -47,8 +52,7 @@ def get_response(self, path = '/search'): url = None try: url, parameter = self.construct_url(path) - # print(url) - response = requests.get(url, parameter, timeout=self.timeout) + response = requests.get(url, parameter, timeout=self.timeout, verify=self.ssl_verify) return response except requests.HTTPError as e: print("fail: " + url)