diff options
author | Markus <markus@venom.fritz.box> | 2024-09-15 14:36:06 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-09-15 14:45:23 +0200 |
commit | d3a795c7e748a1f97be860abfa36b736de618418 (patch) | |
tree | 768f1dd2889915bf9dfe977e462146ba43003075 /searx/engines/qwant.py | |
parent | 55e2f4a97f9a415355d665fbc0c24aff30641120 (diff) | |
download | searxng-d3a795c7e748a1f97be860abfa36b736de618418.tar.gz searxng-d3a795c7e748a1f97be860abfa36b736de618418.zip |
[fix] engine: qwant - detect captchaUrl and raise SearxEngineCaptchaException
So far a CAPTCHA was not recognized in the response of the qwant engine and a
SearxEngineAPIException was raised by mistake. With this patch a CAPTCHA
redirect is recognized and the correct SearxEngineCaptchaException is raised.
Closes: https://github.com/searxng/searxng/issues/3806
Signed-off-by: Markus <markus@venom.fritz.box>
Diffstat (limited to 'searx/engines/qwant.py')
-rw-r--r-- | searx/engines/qwant.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 989fe1445..c30018d85 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -49,7 +49,11 @@ from flask_babel import gettext import babel import lxml -from searx.exceptions import SearxEngineAPIException, SearxEngineTooManyRequestsException +from searx.exceptions import ( + SearxEngineAPIException, + SearxEngineTooManyRequestsException, + SearxEngineCaptchaException, +) from searx.network import raise_for_httperror from searx.enginelib.traits import EngineTraits @@ -187,6 +191,8 @@ def parse_web_api(resp): error_code = data.get('error_code') if error_code == 24: raise SearxEngineTooManyRequestsException() + if search_results.get("data", {}).get("error_data", {}).get("captchaUrl") is not None: + raise SearxEngineCaptchaException() msg = ",".join(data.get('message', ['unknown'])) raise SearxEngineAPIException(f"{msg} ({error_code})") |