.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx_engine.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""
3
Searx (all)
4
"""
5
6
from
json
import
loads
7
from
searx.engines
import
categories
as
searx_categories
8
9
# about
10
about = {
11
"website"
:
'https://github.com/searxng/searxng'
,
12
"wikidata_id"
:
'Q17639196'
,
13
"official_api_documentation"
:
'https://docs.searxng.org/dev/search_api.html'
,
14
"use_official_api"
:
True
,
15
"require_api_key"
:
False
,
16
"results"
:
'JSON'
,
17
}
18
19
categories = searx_categories.keys()
20
21
# search-url
22
instance_urls = []
23
instance_index = 0
24
25
26
# do search-request
27
def
request
(query, params):
28
global
instance_index
# pylint: disable=global-statement
29
params[
'url'
] = instance_urls[instance_index % len(instance_urls)]
30
params[
'method'
] =
'POST'
31
32
instance_index += 1
33
34
params[
'data'
] = {
35
'q'
: query,
36
'pageno'
: params[
'pageno'
],
37
'language'
: params[
'language'
],
38
'time_range'
: params[
'time_range'
],
39
'category'
: params[
'category'
],
40
'format'
:
'json'
,
41
}
42
43
return
params
44
45
46
# get response from search-request
47
def
response
(resp):
48
49
response_json = loads(resp.text)
50
results = response_json[
'results'
]
51
52
for
i
in
(
'answers'
,
'infoboxes'
):
53
results.extend(response_json[i])
54
55
results.extend({
'suggestion'
: s}
for
s
in
response_json[
'suggestions'
])
56
57
results.append({
'number_of_results'
: response_json[
'number_of_results'
]})
58
59
return
results
searx.engines.searx_engine.response
response(resp)
Definition
searx_engine.py:47
searx.engines.searx_engine.request
request(query, params)
Definition
searx_engine.py:27
searx.engines
::1337x
Definition
1337x.py:1
searxng
searx
engines
searx_engine.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0