diff options
Diffstat (limited to 'searx/network/raise_for_httperror.py')
-rw-r--r-- | searx/network/raise_for_httperror.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/searx/network/raise_for_httperror.py b/searx/network/raise_for_httperror.py index 414074977..7fc2b7877 100644 --- a/searx/network/raise_for_httperror.py +++ b/searx/network/raise_for_httperror.py @@ -9,6 +9,7 @@ from searx.exceptions import ( SearxEngineTooManyRequestsException, SearxEngineAccessDeniedException, ) +from searx import get_setting def is_cloudflare_challenge(resp): @@ -33,15 +34,22 @@ def raise_for_cloudflare_captcha(resp): if is_cloudflare_challenge(resp): # https://support.cloudflare.com/hc/en-us/articles/200170136-Understanding-Cloudflare-Challenge-Passage-Captcha- # suspend for 2 weeks - raise SearxEngineCaptchaException(message='Cloudflare CAPTCHA', suspended_time=3600 * 24 * 15) + raise SearxEngineCaptchaException( + message='Cloudflare CAPTCHA', suspended_time=get_setting('search.suspended_times.cf_SearxEngineCaptcha') + ) if is_cloudflare_firewall(resp): - raise SearxEngineAccessDeniedException(message='Cloudflare Firewall', suspended_time=3600 * 24) + raise SearxEngineAccessDeniedException( + message='Cloudflare Firewall', + suspended_time=get_setting('search.suspended_times.cf_SearxEngineAccessDenied'), + ) def raise_for_recaptcha(resp): if resp.status_code == 503 and '"https://www.google.com/recaptcha/' in resp.text: - raise SearxEngineCaptchaException(message='ReCAPTCHA', suspended_time=3600 * 24 * 7) + raise SearxEngineCaptchaException( + message='ReCAPTCHA', suspended_time=get_setting('search.suspended_times.recaptcha_SearxEngineCaptcha') + ) def raise_for_captcha(resp): |