diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-08-19 17:58:37 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-08-20 08:41:03 +0200 |
commit | 77a0f338199b4921deaf365c4339a1d9a716bdd7 (patch) | |
tree | 411c366982f6cbab6c066fad2af05afb3d16073e /searx/engines/duden.py | |
parent | 6f28a69f1209ea33e4dc9daf0f10543003e2cee7 (diff) | |
download | searxng-77a0f338199b4921deaf365c4339a1d9a716bdd7.tar.gz searxng-77a0f338199b4921deaf365c4339a1d9a716bdd7.zip |
[fix] engine duden - don't raise exception on empty result list
Duden expects a word in German, so with query "amazing" the site finds nothing
and respons a 404:
httpx.HTTPStatusError: Client error '404 Not Found' for url\
'https://www.duden.de/suchen/dudenonline/amazing'
[1] https://github.com/searxng/searxng/issues/1543#issuecomment-1193317054
Suggested-by: @allendema [1]
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/duden.py')
-rw-r--r-- | searx/engines/duden.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/searx/engines/duden.py b/searx/engines/duden.py index da4c4f7da..dca566404 100644 --- a/searx/engines/duden.py +++ b/searx/engines/duden.py @@ -7,6 +7,7 @@ import re from urllib.parse import quote, urljoin from lxml import html from searx.utils import extract_text, eval_xpath, eval_xpath_list, eval_xpath_getindex +from searx.network import raise_for_httperror # about about = { @@ -47,6 +48,7 @@ def request(query, params): # after the last page of results, spelling corrections are returned after a HTTP redirect # whatever the page number is params['soft_max_redirects'] = 1 + params['raise_for_httperror'] = False return params @@ -56,6 +58,11 @@ def response(resp): ''' results = [] + if resp.status_code == 404: + return results + + raise_for_httperror(resp) + dom = html.fromstring(resp.text) number_of_results_element = eval_xpath_getindex( |