diff --git a/searx/engines/baidu.py b/searx/engines/baidu.py index 29c9c0e4d..57d1ed444 100644 --- a/searx/engines/baidu.py +++ b/searx/engines/baidu.py @@ -13,7 +13,7 @@ from html import unescape import time import json -from searx.exceptions import SearxEngineAPIException +from searx.exceptions import SearxEngineAPIException, SearxEngineCaptchaException from searx.utils import html_to_text about = { @@ -89,10 +89,14 @@ def request(query, params): query_params["paramList"] += f",timestamp_range={past}-{now}" params["url"] = f"{query_url}?{urlencode(query_params)}" + params["allow_redirects"] = False return params def response(resp): + # Detect Baidu Captcha, it will redirect to wappass.baidu.com + if 'wappass.baidu.com/static/captcha' in resp.headers.get('Location', ''): + raise SearxEngineCaptchaException() text = resp.text if baidu_category == 'images':