.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.deepl Namespace Reference

Functions

 request (_query, params)
 
 response (resp)
 

Variables

dict about
 
str engine_type = 'online_dictionary'
 
list categories = ['general', 'translate']
 
str url = 'https://api-free.deepl.com/v2/translate'
 
 api_key = None
 

Detailed Description

Deepl translation engine

Function Documentation

◆ request()

searx.engines.deepl.request ( _query,
params )
pre-request callback

params<dict>:

- ``method`` : POST/GET
- ``headers``: {}
- ``data``: {}  # if method == POST
- ``url``: ''
- ``category``: 'search category'
- ``pageno``: 1  # number of the requested page

Definition at line 22 of file deepl.py.

22def request(_query, params):
23 '''pre-request callback
24
25 params<dict>:
26
27 - ``method`` : POST/GET
28 - ``headers``: {}
29 - ``data``: {} # if method == POST
30 - ``url``: ''
31 - ``category``: 'search category'
32 - ``pageno``: 1 # number of the requested page
33 '''
34
35 params['url'] = url
36 params['method'] = 'POST'
37 params['data'] = {'auth_key': api_key, 'text': params['query'], 'target_lang': params['to_lang'][1]}
38
39 return params
40
41

◆ response()

searx.engines.deepl.response ( resp)

Definition at line 42 of file deepl.py.

42def response(resp):
43 results = []
44 result = loads(resp.text)
45 translations = result['translations']
46
47 infobox = "<dl>"
48
49 for translation in translations:
50 infobox += f"<dd>{translation['text']}</dd>"
51
52 infobox += "</dl>"
53
54 results.append({'answer': infobox})
55
56 return results

Variable Documentation

◆ about

dict searx.engines.deepl.about
Initial value:
1= {
2 "website": 'https://deepl.com',
3 "wikidata_id": 'Q43968444',
4 "official_api_documentation": 'https://www.deepl.com/docs-api',
5 "use_official_api": True,
6 "require_api_key": True,
7 "results": 'JSON',
8}

Definition at line 6 of file deepl.py.

◆ api_key

searx.engines.deepl.api_key = None

Definition at line 19 of file deepl.py.

◆ categories

list searx.engines.deepl.categories = ['general', 'translate']

Definition at line 16 of file deepl.py.

◆ engine_type

str searx.engines.deepl.engine_type = 'online_dictionary'

Definition at line 15 of file deepl.py.

◆ url

str searx.engines.deepl.url = 'https://api-free.deepl.com/v2/translate'

Definition at line 18 of file deepl.py.