Skip to content

Commit 264be6d

Browse files
authored
Merge pull request #69 from gutoarraes/augusto-get-html
Suggested upgrade to the SerpApiClient.get_html() method
2 parents 936f201 + 6816b81 commit 264be6d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

serpapi/serp_api_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def get_html(self):
6565
"""Returns:
6666
Raw HTML search result from Google
6767
"""
68+
self.params_dict["output"] = "html"
6869
return self.get_results()
6970

7071
def get_json(self):
@@ -161,7 +162,7 @@ def get_location(self, q, limit = 5):
161162
self.params_dict["limit"] = limit
162163
buffer = self.get_results('/locations.json')
163164
return json.loads(buffer)
164-
165+
165166
def pagination(self, start = DEFAULT_START, end = DEFAULT_END, page_size = DEFAULT_PAGE_SIZE, limit = DEFAULT_LIMIT):
166167
"""Return:
167168
Generator to iterate the search results pagination

tests/test_google_search.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ def test_get_html(self):
6060
search = GoogleSearch({"q": "Coffee", "location": "Austin,Texas"})
6161
data = search.get_html()
6262
self.assertGreater(len(data), 10)
63+
self.assertIn("<html", data)
64+
65+
data = search.get_dict()
66+
self.assertEqual(data["search_metadata"]["status"], "Success")
67+
self.assertIsNone(data.get("error"))
6368

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

0 commit comments

Comments
 (0)