mirror of
https://github.com/searxng/searxng.git
synced 2026-09-11 16:56:05 +00:00
[fix] resulthunter: detect blocked requests instead of returning 0 results
This commit is contained in:
@@ -10,6 +10,7 @@ from urllib.parse import urlencode
|
|||||||
from lxml import html
|
from lxml import html
|
||||||
|
|
||||||
from searx import locales
|
from searx import locales
|
||||||
|
from searx.exceptions import SearxEngineResponseException
|
||||||
from searx.result_types import EngineResults
|
from searx.result_types import EngineResults
|
||||||
from searx.utils import eval_xpath_list, eval_xpath, extract_text
|
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:
|
def response(resp: "SXNG_Response") -> EngineResults:
|
||||||
doc = html.fromstring(resp.text)
|
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:
|
match resulthunter_categ:
|
||||||
case "web":
|
case "web":
|
||||||
return _general_results(doc)
|
return _general_results(doc)
|
||||||
|
|||||||
Reference in New Issue
Block a user