summaryrefslogtreecommitdiff
path: root/searx/engines/duckduckgo.py
diff options
context:
space:
mode:
authorGordon Quad <gordon@niflheim.info>2020-06-13 22:42:16 +0100
committerGordon Quad <gordon@niflheim.info>2020-06-13 22:43:10 +0100
commit385e9b5c9e2d1caa73f99dac0bf1be1c46505121 (patch)
tree12b74edf958dcdbddc660edb92d5eabafa50849a /searx/engines/duckduckgo.py
parent6fb5c6aad920b31599292bdffa1dd2ab2f7d1adc (diff)
downloadsearxng-385e9b5c9e2d1caa73f99dac0bf1be1c46505121.tar.gz
searxng-385e9b5c9e2d1caa73f99dac0bf1be1c46505121.zip
add correction support for duckduckgo
Diffstat (limited to 'searx/engines/duckduckgo.py')
-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