Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] engine: qwant - detect captchaUrl and raise SearxEngineCaptchaException

Markusd3a795c7e748
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})")