.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
translated.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""MyMemory Translated
3
4
"""
5
6
# about
7
about = {
8
"website"
:
'https://mymemory.translated.net/'
,
9
"wikidata_id"
:
None
,
10
"official_api_documentation"
:
'https://mymemory.translated.net/doc/spec.php'
,
11
"use_official_api"
:
True
,
12
"require_api_key"
:
False
,
13
"results"
:
'JSON'
,
14
}
15
16
engine_type =
'online_dictionary'
17
categories = [
'general'
,
'translate'
]
18
url =
'https://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}{key}'
19
web_url =
'https://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
20
weight = 100
21
https_support =
True
22
23
api_key =
''
24
25
26
def
request
(query, params):
# pylint: disable=unused-argument
27
if
api_key:
28
key_form =
'&key='
+ api_key
29
else
:
30
key_form =
''
31
params[
'url'
] = url.format(
32
from_lang=params[
'from_lang'
][1], to_lang=params[
'to_lang'
][1], query=params[
'query'
], key=key_form
33
)
34
return
params
35
36
37
def
response
(resp):
38
results = []
39
results.append(
40
{
41
'url'
: web_url.format(
42
from_lang=resp.search_params[
'from_lang'
][2],
43
to_lang=resp.search_params[
'to_lang'
][2],
44
query=resp.search_params[
'query'
],
45
),
46
'title'
:
'[{0}-{1}] {2}'
.
format
(
47
resp.search_params[
'from_lang'
][1], resp.search_params[
'to_lang'
][1], resp.search_params[
'query'
]
48
),
49
'content'
: resp.json()[
'responseData'
][
'translatedText'
],
50
}
51
)
52
return
results
searx.engines.translated.request
request(query, params)
Definition
translated.py:26
searx.engines.translated.response
response(resp)
Definition
translated.py:37
searx.format
format
Definition
__init__.py:94
searxng
searx
engines
translated.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0