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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['dictionaries']
 
bool paging = True
 
str base_url = 'https://www.duden.de/'
 
str search_url = base_url + 'suchen/dudenonline/{query}?search_api_fulltext=&page={offset}'
 

Detailed Description

Duden

Function Documentation

◆ request()

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

Definition at line 31 of file duden.py.

31def request(query, params):
32
33 offset = params['pageno'] - 1
34 if offset == 0:
35 search_url_fmt = base_url + 'suchen/dudenonline/{query}'
36 params['url'] = search_url_fmt.format(query=quote(query))
37 else:
38 params['url'] = search_url.format(offset=offset, query=quote(query))
39 # after the last page of results, spelling corrections are returned after a HTTP redirect
40 # whatever the page number is
41 params['soft_max_redirects'] = 1
42 params['raise_for_httperror'] = False
43 return params
44
45

◆ response()

searx.engines.duden.response ( resp)

Definition at line 46 of file duden.py.

46def response(resp):
47 results = []
48
49 if resp.status_code == 404:
50 return results
51
52 raise_for_httperror(resp)
53
54 dom = html.fromstring(resp.text)
55
56 number_of_results_element = eval_xpath_getindex(
57 dom, '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()', 0, default=None
58 )
59 if number_of_results_element is not None:
60 number_of_results_string = re.sub('[^0-9]', '', number_of_results_element)
61 results.append({'number_of_results': int(number_of_results_string)})
62
63 for result in eval_xpath_list(dom, '//section[not(contains(@class, "essay"))]'):
64 url = eval_xpath_getindex(result, './/h2/a', 0).get('href')
65 url = urljoin(base_url, url)
66 title = eval_xpath(result, 'string(.//h2/a)').strip()
67 content = extract_text(eval_xpath(result, './/p'))
68 # append result
69 results.append({'url': url, 'title': title, 'content': content})
70
71 return results

Variable Documentation

◆ about

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

Definition at line 13 of file duden.py.

◆ base_url

str searx.engines.duden.base_url = 'https://www.duden.de/'

Definition at line 27 of file duden.py.

◆ categories

list searx.engines.duden.categories = ['dictionaries']

Definition at line 23 of file duden.py.

◆ paging

bool searx.engines.duden.paging = True

Definition at line 24 of file duden.py.

◆ search_url

str searx.engines.duden.search_url = base_url + 'suchen/dudenonline/{query}?search_api_fulltext=&page={offset}'

Definition at line 28 of file duden.py.