[fix] startpage engine: properly display CAPTCHA if redirect page is seen (#5380)

Fixes an issue where startpage engine would display parsing error
(`json.decoder.JSONDecodeError`) when returning CAPTCHA redirect page.

The fix simply checks if response header has `Location` set, and if it starts
with `https://www.startpage.com/sp/captcha`, it will raise a CAPTCHA exception
before trying to parse the data.
This commit is contained in:
Aadniz 2025-10-26 11:32:45 +01:00 committed by GitHub
parent 4ca75a0450
commit 22e1d30017
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -404,6 +404,10 @@ def _get_image_result(result) -> dict[str, t.Any] | None:
def response(resp):
categ = startpage_categ.capitalize()
results_raw = '{' + extr(resp.text, f"React.createElement(UIStartpage.AppSerp{categ}, {{", '}})') + '}}'
if resp.headers.get('Location', '').startswith("https://www.startpage.com/sp/captcha"):
raise SearxEngineCaptchaException()
results_json = loads(results_raw)
results_obj = results_json.get('render', {}).get('presenter', {}).get('regions', {})