From 385e9b5c9e2d1caa73f99dac0bf1be1c46505121 Mon Sep 17 00:00:00 2001 From: Gordon Quad Date: Sat, 13 Jun 2020 22:42:16 +0100 Subject: [PATCH] add correction support for duckduckgo --- searx/engines/duckduckgo.py | 6 ++++++ 1 file changed, 6 insertions(+) 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