diff options
author | Alexandre Flament <alex@al-f.net> | 2020-12-04 20:42:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-04 20:42:45 +0100 |
commit | cdceec1cbb2ca894572396e0a68c2d09b0769231 (patch) | |
tree | 3205b87615421c6f725a984567da1cd821e770f1 /searx | |
parent | d9494283ccf122ea9791a5afeedb09890c908493 (diff) | |
parent | f0054d67f11bf954cd137684950b6aea2a3956b6 (diff) | |
download | searxng-cdceec1cbb2ca894572396e0a68c2d09b0769231.tar.gz searxng-cdceec1cbb2ca894572396e0a68c2d09b0769231.zip |
Merge pull request #2354 from dalf/fix-wikipedia
[fix] wikipedia engine: don't raise an error when the query is not found
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/wikipedia.py | 4 | ||||
-rw-r--r-- | searx/search.py | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py index 620ec3c14..9fce170eb 100644 --- a/searx/engines/wikipedia.py +++ b/searx/engines/wikipedia.py @@ -37,13 +37,15 @@ def request(query, params): language=url_lang(params['language'])) params['headers']['User-Agent'] = searx_useragent() + params['raise_for_status'] = False + params['soft_max_redirects'] = 2 return params # get response from search-request def response(resp): - if not resp.ok: + if resp.status_code == 404: return [] results = [] diff --git a/searx/search.py b/searx/search.py index 8898f1576..8c2ad8d72 100644 --- a/searx/search.py +++ b/searx/search.py @@ -143,7 +143,8 @@ def send_http_request(engine, request_params): response = req(request_params['url'], **request_args) # check HTTP status - response.raise_for_status() + if request_params.get('raise_for_status'): + response.raise_for_status() # check soft limit of the redirect count if len(response.history) > soft_max_redirects: @@ -340,7 +341,8 @@ def default_request_params(): 'url': '', 'cookies': {}, 'verify': True, - 'auth': None + 'auth': None, + 'raise_for_status': True } |