.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
opensemantic.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Open Semantic Search
3
4
"""
5
6
from
json
import
loads
7
from
urllib.parse
import
quote
8
from
dateutil
import
parser
9
10
# about
11
about = {
12
"website"
:
'https://www.opensemanticsearch.org/'
,
13
"wikidata_id"
:
None
,
14
"official_api_documentation"
:
'https://www.opensemanticsearch.org/dev'
,
15
"use_official_api"
:
True
,
16
"require_api_key"
:
False
,
17
"results"
:
'JSON'
,
18
}
19
20
base_url =
'http://localhost:8983/solr/opensemanticsearch/'
21
search_string =
'query?q={query}'
22
23
24
def
request
(query, params):
25
search_path = search_string.format(
26
query=quote(query),
27
)
28
params[
'url'
] = base_url + search_path
29
return
params
30
31
32
def
response
(resp):
33
results = []
34
data = loads(resp.text)
35
docs = data.get(
'response'
, {}).get(
'docs'
, [])
36
37
for
current
in
docs:
38
item = {}
39
item[
'url'
] = current[
'id'
]
40
item[
'title'
] = current[
'title_txt_txt_en'
]
41
if
current.get(
'content_txt'
):
42
item[
'content'
] = current[
'content_txt'
][0]
43
item[
'publishedDate'
] = parser.parse(current[
'file_modified_dt'
])
44
results.append(item)
45
46
return
results
searx.engines.opensemantic.response
response(resp)
Definition
opensemantic.py:32
searx.engines.opensemantic.request
request(query, params)
Definition
opensemantic.py:24
searxng
searx
engines
opensemantic.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0