@@ -0,0 +1,76 @@
3+ @website https://www.duden.de
6+ @results HTML (using search portal)
7+ @stable no (HTML can change)
8+ @parse url, title, content
11+from lxml import html, etree
13+from searx.engines.xpath import extract_text
14+from searx.url_utils import quote
15+from searx import logger
17+categories = ['general']
19+language_support = False
22+base_url = 'https://www.duden.de/'
23+search_url = base_url + 'suchen/dudenonline/{query}?page={offset}'
26+def request(query, params):
27+ '''pre-request callback
31+ data : {} # if method == POST
33+ category: 'search category'
34+ pageno : 1 # number of the requested page
37+ offset = (params['pageno'] - 1)
38+ params['url'] = search_url.format(offset=offset, query=quote(query))
43+ '''post-response callback
44+ resp: requests response object
48+ dom = html.fromstring(resp.text)
51+ number_of_results_string = re.sub('[^0-9]', '', dom.xpath(
52+ '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()')[0]
55+ results.append({'number_of_results': int(number_of_results_string)})
58+ logger.debug("Couldn't read number of results.")
61+ for result in dom.xpath('//section[@class="wide" and not(contains(@style,"overflow:hidden"))]'):
63+ logger.debug("running for %s" % str(result))
64+ link = result.xpath('.//h2/a')[0]
65+ url = link.attrib.get('href')
66+ title = result.xpath('string(.//h2/a)')
67+ content = extract_text(result.xpath('.//p'))
69+ results.append({'url': url,
73+ logger.debug('result parse error in:\n%s', etree.tostring(result, pretty_print=True))