[fix] resulthunter: detect blocked requests instead of returning 0 results

This commit is contained in:
Bnyro
2026-09-05 11:53:19 +02:00
parent 14a9f84c6c
commit 28b61729c7

View File

@@ -10,6 +10,7 @@ from urllib.parse import urlencode
from lxml import html
from searx import locales
from searx.exceptions import SearxEngineResponseException
from searx.result_types import EngineResults
from searx.utils import eval_xpath_list, eval_xpath, extract_text
@@ -112,6 +113,11 @@ def _image_results(doc: "ElementBase") -> EngineResults:
def response(resp: "SXNG_Response") -> EngineResults:
doc = html.fromstring(resp.text)
# if the request was wrong (e.g. missing params), the site doesn't contain a result container
# and instead shows an "Installation required" page to download the resulthunter browser extension
if not eval_xpath(doc, "//div[contains(@class, 'organic-results-container')]"):
raise SearxEngineResponseException()
match resulthunter_categ:
case "web":
return _general_results(doc)