mirror of
https://github.com/karust/openserp.git
synced 2026-08-05 16:53:54 +08:00
Add OpenSERP SDK usage examples
This commit is contained in:
11
examples/quickstart/python-basic-search/README.md
Normal file
11
examples/quickstart/python-basic-search/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Basic search (Python)
|
||||
|
||||
Runs one Google search with the `openserp` SDK and prints the titles and URLs.
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
python main.py
|
||||
```
|
||||
|
||||
Edit the `text`, `engine`, or `limit` in [main.py](main.py) to change the search.
|
||||
To use the hosted API instead of a local server, follow the commented line at the top of the file.
|
||||
16
examples/quickstart/python-basic-search/main.py
Normal file
16
examples/quickstart/python-basic-search/main.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from openserp import OpenSERP
|
||||
|
||||
# Hosted API instead? Get a key at https://openserp.org/dashboard/keys:
|
||||
# with OpenSERP(api_key="<YOUR_API_TOKEN>") as client:
|
||||
with OpenSERP(base_url="http://localhost:7000") as client:
|
||||
response = client.search(
|
||||
engine="google",
|
||||
text="open source search api",
|
||||
region="US",
|
||||
lang="EN",
|
||||
limit=10,
|
||||
)
|
||||
|
||||
for item in response.results:
|
||||
print(f"{item.rank}. {item.title}")
|
||||
print(f" {item.url}")
|
||||
1
examples/quickstart/python-basic-search/requirements.txt
Normal file
1
examples/quickstart/python-basic-search/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
openserp>=0.2.0,<1
|
||||
Reference in New Issue
Block a user