diff options
author | Gordon Quad <gordon@niflheim.info> | 2020-06-13 22:42:16 +0100 |
---|---|---|
committer | Gordon Quad <gordon@niflheim.info> | 2020-06-13 22:43:10 +0100 |
commit | 385e9b5c9e2d1caa73f99dac0bf1be1c46505121 (patch) | |
tree | 12b74edf958dcdbddc660edb92d5eabafa50849a /searx/engines/duckduckgo.py | |
parent | 6fb5c6aad920b31599292bdffa1dd2ab2f7d1adc (diff) | |
download | searxng-385e9b5c9e2d1caa73f99dac0bf1be1c46505121.tar.gz searxng-385e9b5c9e2d1caa73f99dac0bf1be1c46505121.zip |
add correction support for duckduckgo
Diffstat (limited to 'searx/engines/duckduckgo.py')
-rw-r--r-- | searx/engines/duckduckgo.py | 6 |
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 |