summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJayant Sharma <jayant.sharma2023@vitstudent.ac.in>2026-07-09 00:49:11 +0530
committerGitHub <noreply@github.com>2026-07-08 21:19:11 +0200
commit1412926f5c80ffabc90719450578eb98fda9e161 (patch)
treed06a5475281dd97c0ff1c970ce38fe244dd32b18
parent3b573e0f89bd4d0154603c3cb7b8d795c03f7f93 (diff)
[fix] braveapi: strip HTML tags and filter favicon thumbnails (#6381)
-rw-r--r--searx/engines/braveapi.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/searx/engines/braveapi.py b/searx/engines/braveapi.py
index a25258548..4b501c282 100644
--- a/searx/engines/braveapi.py
+++ b/searx/engines/braveapi.py
@@ -31,6 +31,7 @@ from dateutil import parser
from searx.exceptions import SearxEngineAPIException
from searx.result_types import EngineResults
+from searx.utils import html_to_text
if t.TYPE_CHECKING:
from searx.extended_types import SXNG_Response
@@ -75,6 +76,7 @@ def request(query: str, params: "OnlineParams") -> None:
"q": query,
"count": results_per_page,
"offset": (params["pageno"] - 1) * results_per_page,
+ "text_decorations": False,
}
# Apply time filter if specified
@@ -112,14 +114,19 @@ def response(resp: "SXNG_Response") -> EngineResults:
res = EngineResults()
data = resp.json()
- for result in data.get("web", {}).get("results", []):
+ for result in (data.get("web") or {}).get("results", []):
+ thumbnail_obj = result.get("thumbnail")
+ thumbnail = ""
+ if thumbnail_obj and not thumbnail_obj.get("logo", False):
+ thumbnail = thumbnail_obj.get("src") or ""
+
res.add(
res.types.MainResult(
url=result["url"],
- title=result["title"],
- content=result.get("description", ""),
+ title=html_to_text(result["title"]),
+ content=html_to_text(result.get("description", "")),
publishedDate=_extract_published_date(result.get("age")),
- thumbnail=result.get("thumbnail", {}).get("src"),
+ thumbnail=thumbnail,
),
)