diff options
author | allendema_searxng_pi <pi@raspberrypi.local> | 2023-09-09 10:56:19 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-05-24 10:44:17 +0200 |
commit | 68365c8c1d819338337e7729424a435ebf269061 (patch) | |
tree | 1893ff1f8471bb486dcd8fb1c4f463f51e9f09a4 /searx | |
parent | 6c74bc8908c37842bc86f26bea68f7189b1b6554 (diff) | |
download | searxng-68365c8c1d819338337e7729424a435ebf269061.tar.gz searxng-68365c8c1d819338337e7729424a435ebf269061.zip |
[enh] add instant answers from ddg
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/duckduckgo.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index 8a1dafbcf..3ebddd342 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -328,6 +328,19 @@ def response(resp): len_tr_rows = len(tr_rows) offset = 0 + zero_click_info_xpath = '//html/body/form/div/table[2]/tr[2]/td/text()' + zero_click = extract_text(eval_xpath(doc, zero_click_info_xpath)).strip() + + if zero_click: + current_query = resp.search_params["data"].get("q") + + results.append( + { + 'answer': zero_click, + 'url': "https://duckduckgo.com/?" + urlencode({"q": current_query}), + } + ) + while len_tr_rows >= offset + 4: # assemble table rows we need to scrap |