11# User guide
22Scrape Google and other search engines from our fast, easy, and complete API using SerpApi.com
3- This ruby library is meant to scrape and parse results from all major search engine available world wide including Google, Bing, Baidu, Yandex, Yahoo, Ebay, Apple and more using [ SerpApi] ( https://serpapi.com ) .
3+ This python library is meant to scrape and parse results from all major search engines available world wide including Google, Bing, Baidu, Yandex, Yahoo, Ebay, Home depot, Apple and more using [ SerpApi] ( https://serpapi.com ) .
4+ This is an open source project hosted under https://github.com/serpapi/serpapi-python .
5+
46SerpApi.com provides a [ script builder] ( https://serpapi.com/demo ) to get you started quickly.
57
68## Installation
@@ -51,13 +53,17 @@ SerpApi Client uses urllib3 under the hood.
5153The HTTP connection be tuned by setting the following client specific setting.
5254 - retries : attempt to reconnect if the connection failed by default: False
5355 - timeout : connection timeout by default 60s
54- for more details: https://urllib3.readthedocs.io/en/stable/user-guide.html
5556
56- For example:
57+ ``` python
5758parameter = {
58- retries: 5,
59- timeout: 4.0
59+ retries: 5 ,
60+ timeout: 4.0
61+ # regular parameters
6062}
63+ ```
64+
65+ for more details: [ URL LIB3 documentation] ( https://urllib3.readthedocs.io/en/stable/user-guide.html )
66+
6167
6268## Basic example per search engine
6369### Search bing
@@ -77,8 +83,8 @@ pp = pprint.PrettyPrinter(indent=2)
7783pp.pprint(data[' organic_results' ])
7884# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
7985```
80- see : tests/example_search_bing.py
81- ( see https://serpapi.com/bing)[ https://serpapi.com/bing ]
86+ test : tests/example_search_bing.py
87+ [ see https://serpapi.com/bing ] ( https://serpapi.com/bing )
8288
8389### Search baidu
8490``` python
@@ -97,8 +103,8 @@ pp = pprint.PrettyPrinter(indent=2)
97103pp.pprint(data[' organic_results' ])
98104# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
99105```
100- see : tests/example_search_baidu.py
101- ( see https://serpapi.com/baidu)[ https://serpapi.com/baidu ]
106+ test : tests/example_search_baidu.py
107+ [ see https://serpapi.com/baidu ] ( https://serpapi.com/baidu )
102108
103109### Search yahoo
104110``` python
@@ -117,8 +123,8 @@ pp = pprint.PrettyPrinter(indent=2)
117123pp.pprint(data[' organic_results' ])
118124# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
119125```
120- see : tests/example_search_yahoo.py
121- ( see https://serpapi.com/yahoo)[ https://serpapi.com/yahoo ]
126+ test : tests/example_search_yahoo.py
127+ [ see https://serpapi.com/yahoo ] ( https://serpapi.com/yahoo )
122128
123129### Search youtube
124130``` python
@@ -132,14 +138,13 @@ client = serpapi.Client({
132138})
133139data = client.search({
134140' search_query' : ' coffee' ,
135- ' results' : ' video_results' ,
136141})
137142pp = pprint.PrettyPrinter(indent = 2 )
138- pp.pprint(data[' organic_results ' ])
143+ pp.pprint(data[' video_results ' ])
139144# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
140145```
141- see : tests/example_search_youtube.py
142- ( see https://serpapi.com/youtube)[ https://serpapi.com/youtube ]
146+ test : tests/example_search_youtube.py
147+ [ see https://serpapi.com/youtube ] ( https://serpapi.com/youtube )
143148
144149### Search walmart
145150``` python
@@ -158,8 +163,8 @@ pp = pprint.PrettyPrinter(indent=2)
158163pp.pprint(data[' organic_results' ])
159164# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
160165```
161- see : tests/example_search_walmart.py
162- ( see https://serpapi.com/walmart)[ https://serpapi.com/walmart ]
166+ test : tests/example_search_walmart.py
167+ [ see https://serpapi.com/walmart ] ( https://serpapi.com/walmart )
163168
164169### Search ebay
165170``` python
@@ -178,8 +183,8 @@ pp = pprint.PrettyPrinter(indent=2)
178183pp.pprint(data[' organic_results' ])
179184# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
180185```
181- see : tests/example_search_ebay.py
182- ( see https://serpapi.com/ebay)[ https://serpapi.com/ebay ]
186+ test : tests/example_search_ebay.py
187+ [ see https://serpapi.com/ebay ] ( https://serpapi.com/ebay )
183188
184189### Search naver
185190``` python
@@ -193,14 +198,13 @@ client = serpapi.Client({
193198})
194199data = client.search({
195200' query' : ' coffee' ,
196- ' results' : ' ads_results' ,
197201})
198202pp = pprint.PrettyPrinter(indent = 2 )
199- pp.pprint(data[' organic_results ' ])
203+ pp.pprint(data[' ads_results ' ])
200204# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
201205```
202- see : tests/example_search_naver.py
203- ( see https://serpapi.com/naver)[ https://serpapi.com/naver ]
206+ test : tests/example_search_naver.py
207+ [ see https://serpapi.com/naver ] ( https://serpapi.com/naver )
204208
205209### Search home depot
206210``` python
@@ -214,14 +218,13 @@ client = serpapi.Client({
214218})
215219data = client.search({
216220' q' : ' table' ,
217- ' results' : ' products' ,
218221})
219222pp = pprint.PrettyPrinter(indent = 2 )
220- pp.pprint(data[' organic_results ' ])
223+ pp.pprint(data[' products ' ])
221224# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
222225```
223- see : tests/example_search_home_depot.py
224- ( see https://serpapi.com/home_depot)[ https://serpapi.com/home_depot ]
226+ test : tests/example_search_home_depot.py
227+ [ see https://serpapi.com/home_depot ] ( https://serpapi.com/home_depot )
225228
226229### Search apple app store
227230``` python
@@ -240,8 +243,8 @@ pp = pprint.PrettyPrinter(indent=2)
240243pp.pprint(data[' organic_results' ])
241244# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
242245```
243- see : tests/example_search_apple_app_store.py
244- ( see https://serpapi.com/apple_app_store)[ https://serpapi.com/apple_app_store ]
246+ test : tests/example_search_apple_app_store.py
247+ [ see https://serpapi.com/apple_app_store ] ( https://serpapi.com/apple_app_store )
245248
246249### Search duckduckgo
247250``` python
@@ -260,8 +263,8 @@ pp = pprint.PrettyPrinter(indent=2)
260263pp.pprint(data[' organic_results' ])
261264# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
262265```
263- see : tests/example_search_duckduckgo.py
264- ( see https://serpapi.com/duckduckgo)[ https://serpapi.com/duckduckgo ]
266+ test : tests/example_search_duckduckgo.py
267+ [ see https://serpapi.com/duckduckgo ] ( https://serpapi.com/duckduckgo )
265268
266269### Search google scholar
267270``` python
@@ -280,8 +283,27 @@ pp = pprint.PrettyPrinter(indent=2)
280283pp.pprint(data[' organic_results' ])
281284# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
282285```
283- see: tests/example_search_google_scholar.py
284- (see https://serpapi.com/google_scholar)[https://serpapi.com/google_scholar ]
286+ test: tests/example_search_google_scholar.py
287+ [ see https://serpapi.com/google_scholar ] ( https://serpapi.com/google_scholar )
288+
289+ ### Search google autocomplete
290+ ``` ruby
291+ import ' serpapi'
292+ import ' pprint'
293+ import ' os'
294+
295+ ' engine' : ' google_autocomplete' ,
296+ ' api_key' : os.getenv(" API_KEY" )
297+ })
298+ data = client.search({
299+ ' q' : ' coffee' ,
300+ })
301+ pp = pprint.PrettyPrinter (indent= 2 )
302+ pp.pprint(data[' suggestions' ])
303+ # os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
304+ ```
305+ test: tests/example_search_google_autocomplete.py
306+ [ see https://serpapi.com/google_autocomplete ] ( https://serpapi.com/google_autocomplete )
285307
286308### Search google product
287309``` python
@@ -296,14 +318,13 @@ client = serpapi.Client({
296318data = client.search({
297319' q' : ' coffee' ,
298320' product_id' : ' 4172129135583325756' ,
299- ' results' : ' product_results' ,
300321})
301322pp = pprint.PrettyPrinter(indent = 2 )
302- pp.pprint(data[' organic_results ' ])
323+ pp.pprint(data[' product_results ' ])
303324# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
304325```
305- see : tests/example_search_google_product.py
306- ( see https://serpapi.com/google_product)[ https://serpapi.com/google_product ]
326+ test : tests/example_search_google_product.py
327+ [ see https://serpapi.com/google_product ] ( https://serpapi.com/google_product )
307328
308329### Search google reverse image
309330``` python
@@ -317,14 +338,13 @@ client = serpapi.Client({
317338})
318339data = client.search({
319340' image_url' : ' https://i.imgur.com/5bGzZi7.jpg' ,
320- ' results' : ' image_sizes' ,
321341})
322342pp = pprint.PrettyPrinter(indent = 2 )
323- pp.pprint(data[' organic_results ' ])
343+ pp.pprint(data[' image_sizes ' ])
324344# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
325345```
326- see : tests/example_search_google_reverse_image.py
327- ( see https://serpapi.com/google_reverse_image)[ https://serpapi.com/google_reverse_image ]
346+ test : tests/example_search_google_reverse_image.py
347+ [ see https://serpapi.com/google_reverse_image ] ( https://serpapi.com/google_reverse_image )
328348
329349### Search google events
330350``` python
@@ -340,11 +360,11 @@ data = client.search({
340360' q' : ' coffee' ,
341361})
342362pp = pprint.PrettyPrinter(indent = 2 )
343- pp.pprint(data[' organic_results ' ])
363+ pp.pprint(data[' events_results ' ])
344364# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
345365```
346- see : tests/example_search_google_events.py
347- ( see https://serpapi.com/google_events)[ https://serpapi.com/google_events ]
366+ test : tests/example_search_google_events.py
367+ [ see https://serpapi.com/google_events ] ( https://serpapi.com/google_events )
348368
349369### Search google local services
350370``` python
@@ -359,14 +379,13 @@ client = serpapi.Client({
359379data = client.search({
360380' q' : ' Electrician' ,
361381' place_id' : ' ChIJOwg_06VPwokRYv534QaPC8g' ,
362- ' results' : ' local_ads' ,
363382})
364383pp = pprint.PrettyPrinter(indent = 2 )
365- pp.pprint(data[' organic_results ' ])
384+ pp.pprint(data[' local_ads ' ])
366385# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
367386```
368- see : tests/example_search_google_local_services.py
369- ( see https://serpapi.com/google_local_services)[ https://serpapi.com/google_local_services ]
387+ test : tests/example_search_google_local_services.py
388+ [ see https://serpapi.com/google_local_services ] ( https://serpapi.com/google_local_services )
370389
371390### Search google maps
372391``` python
@@ -382,14 +401,13 @@ data = client.search({
382401' q' : ' pizza' ,
383402' ll' : ' @40.7455096,-74.0083012,15.1z' ,
384403' type' : ' search' ,
385- ' results' : ' local_results' ,
386404})
387405pp = pprint.PrettyPrinter(indent = 2 )
388- pp.pprint(data[' organic_results ' ])
406+ pp.pprint(data[' local_results ' ])
389407# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
390408```
391- see : tests/example_search_google_maps.py
392- ( see https://serpapi.com/google_maps)[ https://serpapi.com/google_maps ]
409+ test : tests/example_search_google_maps.py
410+ [ see https://serpapi.com/google_maps ] ( https://serpapi.com/google_maps )
393411
394412### Search google jobs
395413``` python
@@ -403,14 +421,13 @@ client = serpapi.Client({
403421})
404422data = client.search({
405423' q' : ' coffee' ,
406- ' results' : ' jobs_results' ,
407424})
408425pp = pprint.PrettyPrinter(indent = 2 )
409- pp.pprint(data[' organic_results ' ])
426+ pp.pprint(data[' jobs_results ' ])
410427# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
411428```
412- see : tests/example_search_google_jobs.py
413- ( see https://serpapi.com/google_jobs)[ https://serpapi.com/google_jobs ]
429+ test : tests/example_search_google_jobs.py
430+ [ see https://serpapi.com/google_jobs ] ( https://serpapi.com/google_jobs )
414431
415432### Search google play
416433``` python
@@ -423,15 +440,18 @@ client = serpapi.Client({
423440' api_key' : os.getenv(" API_KEY" )
424441})
425442data = client.search({
426- ' q' : ' coffee' ,
427- ' store' : ' apps' ,
443+ " engine" : " google_play" ,
444+ " q" : " maps" ,
445+ " hl" : " en" ,
446+ " gl" : " us" ,
447+ " store" : " apps"
428448})
429- pp = pprint.PrettyPrinter(indent = 2 )
449+ # pp = pprint.PrettyPrinter(indent=2)
430450pp.pprint(data[' organic_results' ])
431451# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
432452```
433- see : tests/example_search_google_play.py
434- ( see https://serpapi.com/google_play)[ https://serpapi.com/google_play ]
453+ test : tests/example_search_google_play.py
454+ [ see https://serpapi.com/google_play ] ( https://serpapi.com/google_play )
435455
436456### Search google images
437457``` python
@@ -447,14 +467,13 @@ data = client.search({
447467' engine' : ' google' ,
448468' tbm' : ' isch' ,
449469' q' : ' coffee' ,
450- ' results' : ' images_results' ,
451470})
452471pp = pprint.PrettyPrinter(indent = 2 )
453- pp.pprint(data[' organic_results ' ])
472+ pp.pprint(data[' images_results ' ])
454473# os.getenv("API_KEY") captures the secret user API available from http://serpapi.com
455474```
456- see : tests/example_search_google_images.py
457- ( see https://serpapi.com/google_images)[ https://serpapi.com/google_images ]
475+ test : tests/example_search_google_images.py
476+ [ see https://serpapi.com/google_images ] ( https://serpapi.com/google_images )
458477
459478## Developer's note
460479### Key goals
0 commit comments