mirror of
https://github.com/searxng/searxng.git
synced 2025-11-20 13:33:16 -05:00
[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:
parent
4ca75a0450
commit
22e1d30017
@ -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', {})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user