summaryrefslogtreecommitdiff
path: root/searx/engines/duden.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2019-12-24 13:33:07 +0100
committerGitHub <noreply@github.com>2019-12-24 13:33:07 +0100
commitfb668e2075484084a1f7a9b205ecbe7957ea5e8e (patch)
treec6f2e83d9d222d69d79348faac342c07c32dbbf3 /searx/engines/duden.py
parentf407dd8ef4e3f6c82bef31f678139d6db2a4d810 (diff)
parent6d232e9b695c2553b7594efe00c4f63aa96fc62d (diff)
Merge branch 'master' into libgen
Diffstat (limited to 'searx/engines/duden.py')
-rw-r--r--searx/engines/duden.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/searx/engines/duden.py b/searx/engines/duden.py
index 444f18c1f..cf2f1a278 100644
--- a/searx/engines/duden.py
+++ b/searx/engines/duden.py
@@ -11,6 +11,7 @@
from lxml import html, etree
import re
from searx.engines.xpath import extract_text
+from searx.utils import eval_xpath
from searx.url_utils import quote, urljoin
from searx import logger
@@ -52,9 +53,9 @@ def response(resp):
dom = html.fromstring(resp.text)
try:
- number_of_results_string = re.sub('[^0-9]', '', dom.xpath(
- '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()')[0]
- )
+ number_of_results_string =\
+ re.sub('[^0-9]', '',
+ eval_xpath(dom, '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()')[0])
results.append({'number_of_results': int(number_of_results_string)})
@@ -62,12 +63,12 @@ def response(resp):
logger.debug("Couldn't read number of results.")
pass
- for result in dom.xpath('//section[not(contains(@class, "essay"))]'):
+ for result in eval_xpath(dom, '//section[not(contains(@class, "essay"))]'):
try:
- url = result.xpath('.//h2/a')[0].get('href')
+ url = eval_xpath(result, './/h2/a')[0].get('href')
url = urljoin(base_url, url)
- title = result.xpath('string(.//h2/a)').strip()
- content = extract_text(result.xpath('.//p'))
+ title = eval_xpath(result, 'string(.//h2/a)').strip()
+ content = extract_text(eval_xpath(result, './/p'))
# append result
results.append({'url': url,
'title': title,