-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME.md.erb
165 lines (117 loc) · 6.44 KB
/
README.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<%-
def snippet(format, path)
lines = File.new(path).readlines
stop = lines.size - 1
slice = lines[7..stop]
slice.reject! { |l| l.match?(/(^# |assert )/) }
buf = slice.map { |l| l.gsub(/(^\s{2})/, '').gsub(/^\s*$/, '') }.join
url = 'https://github.com/serpapi/serpapi-python/blob/master/' + path
%Q(```#{format}\nimport serpapi\nimport pprint\nimport os\n\n#{buf}```\ntest: [#{path}](#{url}))
end
-%>
<div align="center">
<h1 align="center">SerpApi Python Library & Package</h1>
<img src="https://user-images.githubusercontent.com/78694043/233921372-bb57c347-9005-4b59-8f09-993698a87eb6.svg" width="600" alt="serpapi python library logo">
<!-- <a href="https://badge.fury.io/py/serpapi-python">![Package](https://badge.fury.io/py/serpapi.svg)</a>
<a href="https://pepy.tech/project/serpapi-python">![Downloads](https://static.pepy.tech/personalized-badge/serpapi?period=month&units=international_system&left_color=grey&right_color=brightgreen&left_text=Downloads)</a> -->
[![serpapi-python](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml/badge.svg)](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml)
</div>
This repository is the home of the *soon–to–be* official Python API wrapper for [SerpApi](https://serpapi.com). This `serpapi` module allows you to access search data in your Python application.
[SerpApi](https://serpapi.com) supports Google, Google Maps, Google Shopping, Bing, Baidu, Yandex, Yahoo, eBay, App Stores, and more. Check out the [documentation](https://serpapi.com/search-api) for a full list.
## Current Status
This project is under development, and will be released to the public on PyPi soon.
## Installation
To install the `serpapi` package, simply run the following command:
```bash
$ pip install serpapi
```
Please note that this package is separate from the *soon–to–be* legacy `serpapi` module, which is currently available on PyPi as `google-search-results`.
## Usage
Let's start by searching for Coffee on Google:
```pycon
>>> import serpapi
>>> s = serpapi.search(q="Coffee", engine="google", location="Austin, Texas", hl="en", gl="us")
```
The `s` variable now contains a `SerpResults` object, which acts just like a standard dictionary, with some convenient functions added on top.
Let's print the first result:
```pycon
>>> s["organic_results"][0]["link"]
'https://en.wikipedia.org/wiki/Coffee'
```
Let's print the title of the first result, but in a more Pythonic way:
```pycon
>>> s["organic_results"][0].get("title")
'Coffee - Wikipedia'
```
The [SerpApi.com API Documentation](https://serpapi.com/search-api) contains a list of all the possible parameters that can be passed to the API.
## Documentation
Documentation is [available on Read the Docs](https://serpapi-python.readthedocs.io/en/latest/).
## Examples in python
Here is how to calls the APIs.
### Search bing
<%= snippet('python', 'tests/example_search_bing_test.py') %>
see: [serpapi.com/bing-search-api](https://serpapi.com/bing-search-api)
### Search baidu
<%= snippet('python', 'tests/example_search_baidu_test.py') %>
see: [serpapi.com/baidu-search-api](https://serpapi.com/baidu-search-api)
### Search yahoo
<%= snippet('python', 'tests/example_search_yahoo_test.py') %>
see: [serpapi.com/yahoo-search-api](https://serpapi.com/yahoo-search-api)
### Search youtube
<%= snippet('python', 'tests/example_search_youtube_test.py') %>
see: [serpapi.com/youtube-search-api](https://serpapi.com/youtube-search-api)
### Search walmart
<%= snippet('python', 'tests/example_search_walmart_test.py') %>
see: [serpapi.com/walmart-search-api](https://serpapi.com/walmart-search-api)
### Search ebay
<%= snippet('python', 'tests/example_search_ebay_test.py') %>
see: [serpapi.com/ebay-search-api](https://serpapi.com/ebay-search-api)
### Search naver
<%= snippet('python', 'tests/example_search_naver_test.py') %>
see: [serpapi.com/naver-search-api](https://serpapi.com/naver-search-api)
### Search home depot
<%= snippet('python', 'tests/example_search_home_depot_test.py') %>
see: [serpapi.com/home-depot-search-api](https://serpapi.com/home-depot-search-api)
### Search apple app store
<%= snippet('python', 'tests/example_search_apple_app_store_test.py') %>
see: [serpapi.com/apple-app-store](https://serpapi.com/apple-app-store)
### Search duckduckgo
<%= snippet('python', 'tests/example_search_duckduckgo_test.py') %>
see: [serpapi.com/duckduckgo-search-api](https://serpapi.com/duckduckgo-search-api)
### Search google
<%= snippet('python', 'tests/example_search_google_test.py') %>
see: [serpapi.com/search-api](https://serpapi.com/search-api)
### Search google scholar
<%= snippet('python', 'tests/example_search_google_scholar_test.py') %>
see: [serpapi.com/google-scholar-api](https://serpapi.com/google-scholar-api)
### Search google autocomplete
<%= snippet('python', 'tests/example_search_google_autocomplete_test.py') %>
see: [serpapi.com/google-autocomplete-api](https://serpapi.com/google-autocomplete-api)
### Search google product
<%= snippet('python', 'tests/example_search_google_product_test.py') %>
see: [serpapi.com/google-product-api](https://serpapi.com/google-product-api)
### Search google reverse image
<%= snippet('python', 'tests/example_search_google_reverse_image_test.py') %>
see: [serpapi.com/google-reverse-image](https://serpapi.com/google-reverse-image)
### Search google events
<%= snippet('python', 'tests/example_search_google_events_test.py') %>
see: [serpapi.com/google-events-api](https://serpapi.com/google-events-api)
### Search google local services
<%= snippet('python', 'tests/example_search_google_local_services_test.py') %>
see: [serpapi.com/google-local-services-api](https://serpapi.com/google-local-services-api)
### Search google maps
<%= snippet('python', 'tests/example_search_google_maps_test.py') %>
see: [serpapi.com/google-maps-api](https://serpapi.com/google-maps-api)
### Search google jobs
<%= snippet('python', 'tests/example_search_google_jobs_test.py') %>
see: [serpapi.com/google-jobs-api](https://serpapi.com/google-jobs-api)
### Search google play
<%= snippet('python', 'tests/example_search_google_play_test.py') %>
see: [serpapi.com/google-play-api](https://serpapi.com/google-play-api)
### Search google images
<%= snippet('python', 'tests/example_search_google_images_test.py') %>
see: [serpapi.com/images-results](https://serpapi.com/images-results)
## License
MIT License.
## Contributing
Bug reports and pull requests are welcome on GitHub. Once dependencies are installed, you can run the tests with `pytest`.