.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
 

Detailed Description

Wordnik (general)

Function Documentation

◆ request()

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

Definition at line 24 of file wordnik.py.

24def request(query, params):
25 params['url'] = f"https://www.wordnik.com/words/{query}"
26 return params
27
28

◆ response()

searx.engines.wordnik.response ( resp)

Definition at line 29 of file wordnik.py.

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