diff options
| author | Aadniz <8147434+Aadniz@users.noreply.github.com> | 2025-10-25 13:43:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-25 13:43:37 +0200 |
| commit | 4ca75a04500d932ffefb48072c63aa35670a952f (patch) | |
| tree | 9811715275a4c1eca764dd30bf1db0e788dbbea5 /searx/engines | |
| parent | 50a4c653dc3b936ba9ffac01beec475baad8e92c (diff) | |
[fix] engine qwant - return forbidden instead of showing parse error (#5377)
Diffstat (limited to 'searx/engines')
| -rw-r--r-- | searx/engines/qwant.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 7398eac91..3c9d40e10 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -53,6 +53,7 @@ from searx.exceptions import ( SearxEngineAPIException, SearxEngineTooManyRequestsException, SearxEngineCaptchaException, + SearxEngineAccessDeniedException, ) from searx.network import raise_for_httperror from searx.enginelib.traits import EngineTraits @@ -184,8 +185,12 @@ def parse_web_api(resp): results = [] - # load JSON result - search_results = loads(resp.text) + # Try to load JSON result + try: + search_results = loads(resp.text) + except ValueError: + search_results = {} + data = search_results.get('data', {}) # check for an API error @@ -195,6 +200,8 @@ def parse_web_api(resp): raise SearxEngineTooManyRequestsException() if search_results.get("data", {}).get("error_data", {}).get("captchaUrl") is not None: raise SearxEngineCaptchaException() + if resp.status_code == 403: + raise SearxEngineAccessDeniedException() msg = ",".join(data.get('message', ['unknown'])) raise SearxEngineAPIException(f"{msg} ({error_code})") |