Skip to content

Commit

Permalink
Merge pull request #69 from gutoarraes/augusto-get-html
Browse files Browse the repository at this point in the history
Suggested upgrade to the SerpApiClient.get_html() method
  • Loading branch information
ilyazub committed Jun 19, 2024
2 parents 936f201 + 6816b81 commit 264be6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion serpapi/serp_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get_html(self):
"""Returns:
Raw HTML search result from Google
"""
self.params_dict["output"] = "html"
return self.get_results()

def get_json(self):
Expand Down Expand Up @@ -161,7 +162,7 @@ def get_location(self, q, limit = 5):
self.params_dict["limit"] = limit
buffer = self.get_results('/locations.json')
return json.loads(buffer)

def pagination(self, start = DEFAULT_START, end = DEFAULT_END, page_size = DEFAULT_PAGE_SIZE, limit = DEFAULT_LIMIT):
"""Return:
Generator to iterate the search results pagination
Expand Down
5 changes: 5 additions & 0 deletions tests/test_google_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def test_get_html(self):
search = GoogleSearch({"q": "Coffee", "location": "Austin,Texas"})
data = search.get_html()
self.assertGreater(len(data), 10)
self.assertIn("<html", data)

data = search.get_dict()
self.assertEqual(data["search_metadata"]["status"], "Success")
self.assertIsNone(data.get("error"))

@unittest.skipIf((os.getenv("API_KEY") == None), "no api_key provided")
def test_get_response(self):
Expand Down

0 comments on commit 264be6d

Please sign in to comment.