summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2020-06-29 06:56:32 +0000
committerGitHub <noreply@github.com>2020-06-29 06:56:32 +0000
commitfe72c7a6fd5622a78e271337a6cbc8416168add5 (patch)
treeaf61bed20c47fec9603fd62cb23142a5be6462d3 /searx
parent0fdd9339d09864ae0f5caca2b8aa9210d8757744 (diff)
parent02017bc624e13341d29ec63a48566dbd618ccee1 (diff)
downloadsearxng-fe72c7a6fd5622a78e271337a6cbc8416168add5.tar.gz
searxng-fe72c7a6fd5622a78e271337a6cbc8416168add5.zip
Merge pull request #2000 from gordon-quad/duckduckgo_correction
add correction support for duckduckgo
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/duckduckgo.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py
index 0d2c0af2d..6e07b5021 100644
--- a/searx/engines/duckduckgo.py
+++ b/searx/engines/duckduckgo.py
@@ -50,6 +50,7 @@ result_xpath = '//div[@class="result results_links results_links_deep web-result
url_xpath = './/a[@class="result__a"]/@href'
title_xpath = './/a[@class="result__a"]'
content_xpath = './/a[@class="result__snippet"]'
+correction_xpath = '//div[@id="did_you_mean"]//a'
# match query's language to a region code that duckduckgo will accept
@@ -125,6 +126,11 @@ def response(resp):
'content': content,
'url': res_url})
+ # parse correction
+ for correction in eval_xpath(doc, correction_xpath):
+ # append correction
+ results.append({'correction': extract_text(correction)})
+
# return results
return results