.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
stract.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Stract is an independent open source search engine. At this state, it's
3
still in beta and hence this implementation will need to be updated once beta
4
ends.
5
6
"""
7
8
from
json
import
dumps
9
from
searx.utils
import
searx_useragent
10
11
about = {
12
"website"
:
"https://stract.com/"
,
13
"use_official_api"
:
True
,
14
"official_api_documentation"
:
"https://stract.com/beta/api/docs/#/search/api"
,
15
"require_api_key"
:
False
,
16
"results"
:
"JSON"
,
17
}
18
categories = [
'general'
]
19
paging =
True
20
21
search_url =
"https://stract.com/beta/api/search"
22
23
24
def
request
(query, params):
25
params[
'url'
] = search_url
26
params[
'method'
] =
"POST"
27
params[
'headers'
] = {
28
'Accept'
:
'application/json'
,
29
'Content-Type'
:
'application/json'
,
30
'User-Agent'
: searx_useragent(),
31
}
32
params[
'data'
] = dumps({
'query'
: query,
'page'
: params[
'pageno'
] - 1})
33
34
return
params
35
36
37
def
response
(resp):
38
results = []
39
40
for
result
in
resp.json()[
"webpages"
]:
41
results.append(
42
{
43
'url'
: result[
'url'
],
44
'title'
: result[
'title'
],
45
'content'
:
''
.join(fragment[
'text'
]
for
fragment
in
result[
'snippet'
][
'text'
][
'fragments'
]),
46
}
47
)
48
49
return
results
searx.engines.stract.response
response(resp)
Definition
stract.py:37
searx.engines.stract.request
request(query, params)
Definition
stract.py:24
searx.utils
Definition
utils.py:1
searxng
searx
engines
stract.py
Generated on Wed May 15 2024 21:10:12 for .oO SearXNG Developer Documentation Oo. by
1.10.0