Skip to content

Commit 299d53b

Browse files
committed
added assertion to get_html() test
1 parent 59d86b2 commit 299d53b

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

serpapi/serp_api_client.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class SerpApiClient(object):
1010
```python
1111
from serpapi import GoogleSearch
1212
search = SerpApiClient({
13-
"q": "Coffee",
14-
"location": "Austin,Texas",
13+
"q": "Coffee",
14+
"location": "Austin,Texas",
1515
"engine": "google",
1616
"api_key": "<your private key>"
1717
})
@@ -61,15 +61,11 @@ def get_results(self, path='/search'):
6161
"""
6262
return self.get_response(path).text
6363

64-
def get_html(self, path='/search'):
64+
def get_html(self, path='/search.html'):
6565
"""Returns:
6666
Raw HTML search result from Google
6767
"""
68-
response = self.get_dictionary() # get search URL with query parameters
69-
response = response['search_metadata']['raw_html_file']
70-
response = requests.get(response).text
71-
# print(response)
72-
return response
68+
return self.get_response(path).text
7369

7470
def get_json(self):
7571
"""Returns:
@@ -99,7 +95,7 @@ def get_dict(self):
9995
return self.get_dictionary()
10096

10197
def get_object(self):
102-
"""Returns:
98+
"""Returns:
10399
Dynamically created python object wrapping the result data structure
104100
"""
105101
# iterative over response hash
@@ -134,7 +130,7 @@ def make_pyobj(self, name, node):
134130
def get_search_archive(self, search_id, format = 'json'):
135131
"""Retrieve search result from the Search Archive API
136132
Parameters:
137-
search_id (int): unique identifier for the search provided by metadata.id
133+
search_id (int): unique identifier for the search provided by metadata.id
138134
format (string): search format: json or html [optional]
139135
Returns:
140136
dict|string: search result from the archive

tests/test_google_search.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ 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)
6364

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

0 commit comments

Comments
 (0)