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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['general']
 
bool paging = False
 
str URL = 'https://www.wordnik.com'
 
str SEARCH_URL = URL + '/words/{query}'
 

Detailed Description

Wordnik (general)

Function Documentation

◆ request()

searx.engines.wordnik.request ( query,
params )

Definition at line 27 of file wordnik.py.

27def request(query, params):
28 params['url'] = SEARCH_URL.format(query=query)
29 logger.debug(f"query_url --> {params['url']}")
30 return params
31
32

◆ response()

searx.engines.wordnik.response ( resp)

Definition at line 33 of file wordnik.py.

33def response(resp):
34 results = []
35
36 raise_for_httperror(resp)
37 dom = fromstring(resp.text)
38 word = extract_text(dom.xpath('//*[@id="headword"]/text()'))
39
40 definitions = []
41 for src in dom.xpath('//*[@id="define"]//h3[@class="source"]'):
42 src_text = extract_text(src).strip()
43 if src_text.startswith('from '):
44 src_text = src_text[5:]
45
46 src_defs = []
47 for def_item in src.xpath('following-sibling::ul[1]/li'):
48 def_abbr = extract_text(def_item.xpath('.//abbr')).strip()
49 def_text = extract_text(def_item).strip()
50 if def_abbr:
51 def_text = def_text[len(def_abbr) :].strip()
52 src_defs.append((def_abbr, def_text))
53
54 definitions.append((src_text, src_defs))
55
56 if not definitions:
57 return results
58
59 infobox = ''
60 for src_text, src_defs in definitions:
61 infobox += f"<small>{src_text}</small>"
62 infobox += "<ul>"
63 for def_abbr, def_text in src_defs:
64 if def_abbr:
65 def_abbr += ": "
66 infobox += f"<li><i>{def_abbr}</i> {def_text}</li>"
67 infobox += "</ul>"
68
69 results.append(
70 {
71 'infobox': word,
72 'content': infobox,
73 }
74 )
75
76 return results

Variable Documentation

◆ about

dict searx.engines.wordnik.about
Initial value:
1= {
2 "website": 'https://www.wordnik.com',
3 "wikidata_id": 'Q8034401',
4 "official_api_documentation": None,
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'HTML',
8}

Definition at line 11 of file wordnik.py.

◆ categories

list searx.engines.wordnik.categories = ['general']

Definition at line 20 of file wordnik.py.

◆ paging

bool searx.engines.wordnik.paging = False

Definition at line 21 of file wordnik.py.

◆ SEARCH_URL

str searx.engines.wordnik.SEARCH_URL = URL + '/words/{query}'

Definition at line 24 of file wordnik.py.

◆ URL

str searx.engines.wordnik.URL = 'https://www.wordnik.com'

Definition at line 23 of file wordnik.py.