Skip to content

Commit d1b2ae5

Browse files
allow SSL verify flag (for GET request) to be set at search object instantiation
1 parent caa9098 commit d1b2ae5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

serpapi/google_search.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ class GoogleSearch(SerpApiClient):
1010
"location": "Austin,Texas",
1111
},
1212
timeout = 60,
13+
ssl_verify = True,
1314
)
1415
data = query.get_json()
1516
```
1617
1718
https://github.com/serpapi/google-search-results-python
1819
"""
1920

20-
def __init__(self, params_dict, timeout = 60):
21-
super(GoogleSearch, self).__init__(params_dict, GOOGLE_ENGINE, timeout)
21+
def __init__(self, params_dict, timeout = 60, ssl_verify = True):
22+
super(GoogleSearch, self).__init__(params_dict, GOOGLE_ENGINE, timeout, ssl_verify)

serpapi/serp_api_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class SerpApiClient(object):
1717
"api_key": "<your private key>",
1818
},
1919
timeout = 60,
20+
ssl_verify = True,
2021
)
2122
data = search.get_json()
2223
```
@@ -27,10 +28,11 @@ class SerpApiClient(object):
2728
BACKEND = "https://serpapi.com"
2829
SERP_API_KEY = None
2930

30-
def __init__(self, params_dict, engine = None, timeout = 60):
31+
def __init__(self, params_dict, engine = None, timeout = 60, ssl_verify = True):
3132
self.params_dict = params_dict
3233
self.engine = engine
3334
self.timeout = timeout
35+
self.ssl_verify = ssl_verify
3436

3537
def construct_url(self, path = "/search"):
3638
self.params_dict['source'] = 'python'
@@ -50,7 +52,7 @@ def get_response(self, path = '/search'):
5052
url = None
5153
try:
5254
url, parameter = self.construct_url(path)
53-
response = requests.get(url, parameter, timeout=self.timeout)
55+
response = requests.get(url, parameter, timeout=self.timeout, verify=self.ssl_verify)
5456
return response
5557
except requests.HTTPError as e:
5658
print("fail: " + url)

0 commit comments

Comments
 (0)