diff options
author | Alexandre Flament <alex@al-f.net> | 2020-12-09 21:23:20 +0100 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-12-11 14:37:08 +0100 |
commit | d703119d3a313a406482b121ee94c6afee3bc307 (patch) | |
tree | 7834dc899b99db4ea3f9f81542e8e029bf5b7d04 /searx/engines/wikipedia.py | |
parent | 033f39bff7b3365256491014140e35aa1e974d4e (diff) | |
download | searxng-d703119d3a313a406482b121ee94c6afee3bc307.tar.gz searxng-d703119d3a313a406482b121ee94c6afee3bc307.zip |
[enh] add raise_for_httperror
check HTTP response:
* detect some comme CAPTCHA challenge (no solving). In this case the engine is suspended for long a time.
* otherwise raise HTTPError as before
the check is done in poolrequests.py (was before in search.py).
update qwant, wikipedia, wikidata to use raise_for_httperror instead of raise_for_status
Diffstat (limited to 'searx/engines/wikipedia.py')
-rw-r--r-- | searx/engines/wikipedia.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py index 000e1af76..54d75108e 100644 --- a/searx/engines/wikipedia.py +++ b/searx/engines/wikipedia.py @@ -14,6 +14,7 @@ from urllib.parse import quote from json import loads from lxml.html import fromstring from searx.utils import match_language, searx_useragent +from searx.raise_for_httperror import raise_for_httperror # search-url search_url = 'https://{language}.wikipedia.org/api/rest_v1/page/summary/{title}' @@ -37,7 +38,7 @@ def request(query, params): language=url_lang(params['language'])) params['headers']['User-Agent'] = searx_useragent() - params['raise_for_status'] = False + params['raise_for_httperror'] = False params['soft_max_redirects'] = 2 return params @@ -47,6 +48,7 @@ def request(query, params): def response(resp): if resp.status_code == 404: return [] + raise_for_httperror(resp) results = [] api_result = loads(resp.text) |