Skip to content

Commit 7c7ec32

Browse files
committed
rename class (remove _results)
1 parent 7f37134 commit 7c7ec32

26 files changed

+189
-185
lines changed

README.md

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pip install google-search-results
2525
## Quick start
2626

2727
```python
28-
from serpapi import GoogleSearchResults
29-
search = GoogleSearchResults({
28+
from serpapi import GoogleSearch
29+
search = GoogleSearch({
3030
"q": "coffee",
3131
"location": "Austin,Texas",
3232
"api_key": "<your secret api key>"
@@ -40,19 +40,19 @@ The SerpApi service (backend)
4040
- searches on Google using the search: q = "coffee"
4141
- parses the messy HTML responses
4242
- return a standardizes JSON response
43-
The GoogleSearchResults class
43+
The GoogleSearch class
4444
- Format the request
4545
- Execute GET http request against SerpApi service
4646
- Parse JSON response into a dictionary
4747
Et voila..
4848

4949
Alternatively, you can search:
50-
- Bing using BingSearchResults class
51-
- Baidu using BaiduSearchResults class
52-
- Yahoo using YahooSearchResults class
53-
- Ebay using EbaySearchResults class
54-
- Yandex using YandexSearchResults class
55-
- GoogleScholar using GoogleScholarSearchResults class
50+
- Bing using BingSearch class
51+
- Baidu using BaiduSearch class
52+
- Yahoo using YahooSearch class
53+
- Ebay using EbaySearch class
54+
- Yandex using YandexSearch class
55+
- GoogleScholar using GoogleScholarSearch class
5656

5757
See the [playground to generate your code.](https://serpapi.com/playground)
5858

@@ -106,7 +106,7 @@ params = {
106106
}
107107

108108
# define the search search
109-
search = GoogleSearchResults(params)
109+
search = GoogleSearch(params)
110110
# override an existing parameter
111111
search.params_dict["location"] = "Portland"
112112
# search format return as raw html
@@ -125,11 +125,11 @@ You can get an API key here if you don't already have one: https://serpapi.com/u
125125

126126
The SerpApi `api_key` can be set globally:
127127
```python
128-
GoogleSearchResults.SERP_API_KEY = "Your Private Key"
128+
GoogleSearch.SERP_API_KEY = "Your Private Key"
129129
```
130130
The SerpApi `api_key` can be provided for each search:
131131
```python
132-
query = GoogleSearchResults({"q": "coffee", "serp_api_key": "Your Private Key"})
132+
query = GoogleSearch({"q": "coffee", "serp_api_key": "Your Private Key"})
133133
```
134134

135135
### Example by specification
@@ -152,8 +152,8 @@ make test
152152
### Location API
153153

154154
```python
155-
from serpapi import GoogleSearchResults
156-
search = GoogleSearchResults({})
155+
from serpapi import GoogleSearch
156+
search = GoogleSearch({})
157157
location_list = search.get_location("Austin", 3)
158158
print(location_list)
159159
```
@@ -179,8 +179,8 @@ The search result are stored in temporary cached.
179179
The previous search can be retrieve from the the cache for free.
180180

181181
```python
182-
from serpapi import GoogleSearchResults
183-
search = GoogleSearchResults({"q": "Coffee", "location": "Austin,Texas"})
182+
from serpapi import GoogleSearch
183+
search = GoogleSearch({"q": "Coffee", "location": "Austin,Texas"})
184184
search_result = search.get_dictionary()
185185
search_id = search_result.get("search_metadata").get("id")
186186
print(search_id)
@@ -189,23 +189,23 @@ print(search_id)
189189
Now let retrieve the previous search from the archive.
190190

191191
```python
192-
archived_search_result = GoogleSearchResults({}).get_search_archive(search_id, 'json')
192+
archived_search_result = GoogleSearch({}).get_search_archive(search_id, 'json')
193193
print(archived_search_result.get("search_metadata").get("id"))
194194
```
195195
it prints the search result from the archive.
196196

197197
### Account API
198198
```python
199-
from serpapi import GoogleSearchResults
200-
search = GoogleSearchResults({})
199+
from serpapi import GoogleSearch
200+
search = GoogleSearch({})
201201
account = search.get_account()
202202
```
203203
it prints your account information.
204204

205205
### Search Bing
206206
```python
207-
from serpapi import BingSearchResults
208-
search = BingSearchResults({"q": "Coffee", "location": "Austin,Texas"})
207+
from serpapi import BingSearch
208+
search = BingSearch({"q": "Coffee", "location": "Austin,Texas"})
209209
data = search.get_json()
210210
```
211211
this code prints baidu search results for coffee as JSON.
@@ -214,17 +214,17 @@ https://serpapi.com/bing-search-api
214214

215215
### Search Baidu
216216
```python
217-
from serpapi import BaiduSearchResults
218-
search = BaiduSearchResults({"q": "Coffee"})
217+
from serpapi import BaiduSearch
218+
search = BaiduSearch({"q": "Coffee"})
219219
data = search.get_json()
220220
```
221221
this code prints baidu search results for coffee as JSON.
222222
https://serpapi.com/baidu-search-api
223223

224224
### Search Yandex
225225
```python
226-
from serpapi import YandexSearchResults
227-
search = YandexSearchResults({"text": "Coffee"})
226+
from serpapi import YandexSearch
227+
search = YandexSearch({"text": "Coffee"})
228228
data = search.get_json()
229229
```
230230
this code prints yandex search results for coffee as JSON.
@@ -233,8 +233,8 @@ https://serpapi.com/yandex-search-api
233233

234234
### Search Yahoo
235235
```python
236-
from serpapi import YahooSearchResults
237-
search = YahooSearchResults({"p": "Coffee"})
236+
from serpapi import YahooSearch
237+
search = YahooSearch({"p": "Coffee"})
238238
data = search.get_json()
239239
```
240240
this code prints yahoo search results for coffee as JSON.
@@ -244,8 +244,8 @@ https://serpapi.com/yahoo-search-api
244244

245245
### Search Ebay
246246
```python
247-
from serpapi import EbaySearchResults
248-
search = EbaySearchResults({"_nkw": "Coffee"})
247+
from serpapi import EbaySearch
248+
search = EbaySearch({"_nkw": "Coffee"})
249249
data = search.get_json()
250250
```
251251
this code prints ebay search results for coffee as JSON.
@@ -254,8 +254,8 @@ https://serpapi.com/ebay-search-api
254254

255255
### Search Google Scholar
256256
```python
257-
from serpapi import GoogleScholarSearchResults
258-
search = GoogleScholarSearchResults({"q": "Coffee"})
257+
from serpapi import GoogleScholarSearch
258+
search = GoogleScholarSearch({"q": "Coffee"})
259259
data = search.get_json()
260260
```
261261
this code prints Google Scholar search results.
@@ -272,8 +272,8 @@ This class enables to interact with any search engine supported by SerpApi.com
272272
### Search Google Images
273273

274274
```python
275-
from serpapi import GoogleSearchResults
276-
search = GoogleSearchResults({"q": "coffe", "tbm": "isch"})
275+
from serpapi import GoogleSearch
276+
search = GoogleSearch({"q": "coffe", "tbm": "isch"})
277277
for image_result in search.get_json()['images_results']:
278278
link = image_result["original"]
279279
try:
@@ -292,8 +292,8 @@ https://github.com/serpapi/showcase-serpapi-tensorflow-keras-image-training
292292
### Search Google News
293293

294294
```python
295-
from serpapi import GoogleSearchResults
296-
search = GoogleSearchResults({
295+
from serpapi import GoogleSearch
296+
search = GoogleSearch({
297297
"q": "coffe", # search search
298298
"tbm": "nws", # news
299299
"tbs": "qdr:d", # last 24h
@@ -311,8 +311,8 @@ this script prints the first 3 pages of the news title for the last 24h.
311311
### Search Google Shopping
312312

313313
```python
314-
from serpapi import GoogleSearchResults
315-
search = GoogleSearchResults({
314+
from serpapi import GoogleSearch
315+
search = GoogleSearch({
316316
"q": "coffe", # search search
317317
"tbm": "shop", # news
318318
"tbs": "p_ord:rv", # last 24h
@@ -332,10 +332,10 @@ With SerpApi, we can build Google search from anywhere in the world.
332332
This code is looking for the best coffee shop per city.
333333

334334
```python
335-
from serpapi import GoogleSearchResults
335+
from serpapi import GoogleSearch
336336
for city in ["new york", "paris", "berlin"]:
337-
location = GoogleSearchResults({}).get_location(city, 1)[0]["canonical_name"]
338-
search = GoogleSearchResults({
337+
location = GoogleSearch({}).get_location(city, 1)[0]["canonical_name"]
338+
search = GoogleSearch({
339339
"q": "best coffee shop", # search search
340340
"location": location,
341341
"num": 1,
@@ -368,13 +368,13 @@ from queue import Queue
368368
import time
369369

370370
# SerpApi search
371-
from serpapi import GoogleSearchResults
371+
from serpapi import GoogleSearch
372372

373373
# store searches
374374
search_queue = Queue()
375375

376376
# SerpApi search
377-
search = GoogleSearchResults({
377+
search = GoogleSearch({
378378
"location": "Austin,Texas",
379379
"async": True
380380
})
@@ -391,7 +391,7 @@ for company in ['amd','nvidia','intel']:
391391
print("wait until all search statuses are cached or success")
392392

393393
# Create regular search
394-
search = GoogleSearchResults({"async": True})
394+
search = GoogleSearch({"async": True})
395395
while not search_queue.empty():
396396
search = search_queue.get()
397397
search_id = search['search_metadata']['id']
@@ -428,6 +428,9 @@ To keep thing simple, this example does only explore search result one at a time
428428
[See example.](https://github.com/serpapi/google-search-results-python/blob/master/tests/test_example.py)
429429

430430
## Change log
431+
2020-10-26 @ 2.0.0
432+
- Reduce class name to <engine>Search
433+
- Add get_raw_json
431434
2020-06-30 @ 1.8.3
432435
- simplify import
433436
- improve package for python 3.5+
@@ -438,7 +441,7 @@ To keep thing simple, this example does only explore search result one at a time
438441
2019-11-10 @ 1.7.1
439442
- increase engine parameter priority over engine value set in the class
440443
2019-09-12 @ 1.7
441-
- Change namespace "from lib." instead: "from serpapi import GoogleSearchResults"
444+
- Change namespace "from lib." instead: "from serpapi import GoogleSearch"
442445
- Support for Bing and Baidu
443446
2019-06-25 @ 1.6
444447
- New search engine supported: Baidu and Bing

README.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ Quick start
3232

3333
.. code-block:: python
3434
35-
from serpapi import GoogleSearchResults
36-
search = GoogleSearchResults({"q": "coffee", "location": "Austin,Texas", "api_key": "secretKey"})
35+
from serpapi import GoogleSearch
36+
search = GoogleSearch({"q": "coffee", "location": "Austin,Texas", "api_key": "secretKey"})
3737
result = search.get_dict()
3838
3939
This example runs a search about "coffee" using your secret api key.
@@ -44,7 +44,7 @@ The Serp API service (backend)
4444
* parses the messy HTML responses
4545
* return a standardizes JSON response
4646

47-
The GoogleSearchResults class
47+
The GoogleSearch class
4848

4949
* Format the request
5050
* Execute GET http request against Serp API service
@@ -54,12 +54,12 @@ Et voila..
5454

5555
Alternatively, you can search:
5656

57-
- Bing using BingSearchResults class
58-
- Baidu using BaiduSearchResults class
59-
- Yahoo using YahooSearchResults class
60-
- Ebay using EbaySearchResults class
61-
- Yandex using YandexSearchResults class
62-
- GoogleScholar using GoogleScholarSearchResults class
57+
- Bing using BingSearch class
58+
- Baidu using BaiduSearch class
59+
- Yahoo using YahooSearch class
60+
- Ebay using EbaySearch class
61+
- Yandex using YandexSearch class
62+
- GoogleScholar using GoogleScholarSearch class
6363

6464
See the `playground to generate your code. <https://serpapi.com/playground>`_
6565

serpapi/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from .serp_api_client import SerpApiClient
2-
from .baidu_search_results import BaiduSearchResults
3-
from .google_search_results import GoogleSearchResults
4-
from .yahoo_search_results import YahooSearchResults
5-
from .bing_search_results import BingSearchResults
6-
from .yandex_search_results import YandexSearchResults
7-
from .google_scholar_search_results import GoogleScholarSearchResults
8-
from .ebay_search_results import EbaySearchResults
2+
from .baidu_search import BaiduSearch
3+
from .google_search import GoogleSearch
4+
from .yahoo_search import YahooSearch
5+
from .bing_search import BingSearch
6+
from .yandex_search import YandexSearch
7+
from .google_scholar_search import GoogleScholarSearch
8+
from .ebay_search import EbaySearch
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
from serpapi.serp_api_client import *
22

3-
class BaiduSearchResults(SerpApiClient):
4-
"""BaiduSearchResults enables to search baidu and parse the result.
3+
class BaiduSearch(SerpApiClient):
4+
"""BaiduSearch enables to search baidu and parse the result.
55
```python
6-
from serpapi import BaiduSearchResults
7-
query = BaiduSearchResults({"q": "coffee"})
6+
from serpapi import BaiduSearch
7+
query = BaiduSearch({"q": "coffee"})
88
data = query.get_json()
99
```
1010
1111
doc: https://serpapi.com/baidu-search-api
1212
"""
1313

1414
def __init__(self, params_dict):
15-
super(BaiduSearchResults, self).__init__(params_dict, BAIDU_ENGINE)
15+
super(BaiduSearch, self).__init__(params_dict, BAIDU_ENGINE)
1616

1717
def get_location(self, q, limit = 5):
1818
raise "location is not supported by Baidu search engine at this time"

serpapi/bing_search.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from serpapi.serp_api_client import *
2+
3+
class BingSearch(SerpApiClient):
4+
"""BingSearch enables to search bing and parse the result.
5+
```python
6+
from serpapi import BingSearch
7+
query = BingSearch({"q": "coffee", "location": "Austin,Texas"})
8+
data = query.get_json()
9+
```
10+
11+
doc: https://serpapi.com/bing-search-api
12+
"""
13+
14+
def __init__(self, params_dict):
15+
super(BingSearch, self).__init__(params_dict, BING_ENGINE)

serpapi/bing_search_results.py

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
from serpapi.serp_api_client import *
22

3-
class EbaySearchResults(SerpApiClient):
4-
"""EbaySearchResults enables to search ebay and parse the result.
3+
class EbaySearch(SerpApiClient):
4+
"""EbaySearch enables to search ebay and parse the result.
55
```python
6-
from serpapi import EbaySearchResults
7-
query = EbaySearchResults({"_nkw": "coffee"})
6+
from serpapi import EbaySearch
7+
query = EbaySearch({"_nkw": "coffee"})
88
data = query.get_json()
99
```
1010
1111
doc: https://serpapi.com/ebay-search-api
1212
"""
1313

1414
def __init__(self, params_dict):
15-
super(EbaySearchResults, self).__init__(params_dict, EBAY_ENGINE)
15+
super(EbaySearch, self).__init__(params_dict, EBAY_ENGINE)
1616

1717
def get_location(self, q, limit = 5):
1818
raise "location is not supported by Ebay search engine at this time"

0 commit comments

Comments
 (0)