Skip to content

Commit

Permalink
Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
karust committed Aug 6, 2023
1 parent a3455b5 commit b040b24
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ API access for search engines results if available isn't free.

Using OpenSERP, you can get search results from **Google**, **Yandex**, **Baidu** via API or CLI!

See [Docker](#docker) and [CLI](#cli) usage examples below.
See [Docker](#docker) and [CLI](#cli) usage examples below ([search](#search), [images](#images)).

## Docker usage <a name="docker"></a> 🐳
* Run API server:
Expand All @@ -21,13 +21,6 @@ docker run -p 127.0.0.1:7000:7000 -it karust/openserp serve -a 0.0.0.0 -p 7000
docker-compose up --build
```

### *Example request*
Get 20 **Google** results for `hello world`, only in English:
```
GET http:/127.0.0.1:7000/google/search?lang=EN&limit=20&text=hello world
```
You can replace `google` to `yandex` or `baidu` in query to change search engine.

### Request parameters
| Param | Description |
|-------|--------------------------------------------------------------|
Expand All @@ -36,7 +29,16 @@ You can replace `google` to `yandex` or `baidu` in query to change search engine
| date | Date in `YYYYMMDD..YYYYMMDD` format (e.g. 20181010..20231010) |
| file | File extension to search (e.g. `PDF`, `DOC`) |
| site | Search within a specific website |
| limit | Limit the number of results |
| limit | Limit the number of results

### **Search**
### *Example request*
Get 20 **Google** results for `hello world`, only in English:
```
GET http:/127.0.0.1:7000/google/search?lang=EN&limit=20&text=hello world
```
You can replace `google` to `yandex` or `baidu` in query to change search engine.
|

### *Example response*
```JSON
Expand All @@ -49,6 +51,23 @@ You can replace `google` to `yandex` or `baidu` in query to change search engine
},
]
```
### **Images**
### *Example request*
Get 100 **Google** results for `golden puppy`:
```
GET http://127.0.0.1:7000/google/image?text=golden puppy&limit=100
```
### *Example response*
```JSON
[
{
"rank": 1,
"url": "https://en.wikipedia.org/wiki/%22Hello,_World!%22_program",
"title": "\"Hello, World!\" program",
"description": "A \"Hello, World!\" program is generally a computer program that ignores any input, and outputs or displays a message similar to \"Hello, World!\"."
},
]
```

## CLI <a name="cli"></a> ⌨️
* Use `-h` flag to see commands.
Expand Down
4 changes: 3 additions & 1 deletion google/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (gogl *Google) SearchImage(query core.Query) ([]core.SearchResult, error) {
continue
}

for i, r := range resultElements[len(searchResultsMap):] {
for i, r := range resultElements {
// TODO: parse AF_initDataCallback to optimize instead of this?
err := r.Click(proto.InputMouseButtonRight, 1)
if err != nil {
Expand Down Expand Up @@ -271,6 +271,8 @@ func (gogl *Google) SearchImage(query core.Query) ([]core.SearchResult, error) {
Description: fmt.Sprintf("Height:%v, Width:%v, Source Page: %v", imgSrc.Height, imgSrc.Width, imgSrc.PageURL),
}
searchResultsMap[*dataID] = gR

r.Remove()
}

if !gogl.LeavePageOpen {
Expand Down

0 comments on commit b040b24

Please sign in to comment.