Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions serpapi/serp_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ 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 self.engine and 'engine' not in self.params_dict:
self.params_dict['engine'] = self.engine
Comment on lines -31 to +32

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SerpApiClient.construct_url refactored with the following changes:

return self.BACKEND + path, self.params_dict

def get_results(self, path = '/search'):
Expand Down Expand Up @@ -94,8 +93,7 @@ def get_location(self, q, limit = 5):
Returns:
Dict: Location matching q
"""
self.params_dict = {}
self.params_dict["output"] = "json"
self.params_dict = {"output": "json"}
Comment on lines -97 to +96

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SerpApiClient.get_location refactored with the following changes:

self.params_dict["q"] = q
self.params_dict["limit"] = limit
return json.loads(self.get_results('/locations.json'))
Expand Down
2 changes: 1 addition & 1 deletion testwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_query():
if len(sys.argv) == 5:
params['country'] = sys.argv[4]
if len(sys.argv) == 6:
params['num_results'] = sys.argv[5] if sys.argv[5] else None
params['num_results'] = sys.argv[5] or None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_query refactored with the following changes:

# print query, location
query_instance = QUERY(None)
return query_instance.retrieve_html(params)
Expand Down