mirror of
https://github.com/searxng/searxng.git
synced 2026-07-25 01:11:24 +00:00
[fix] kagi: results contain HTML tags
This commit is contained in:
@@ -46,11 +46,10 @@ To enable Kagi, add the following to the ``engines`` seciton of
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import typing as t
|
import typing as t
|
||||||
import html
|
|
||||||
|
|
||||||
from searx.extended_types import SXNG_Response
|
from searx.extended_types import SXNG_Response
|
||||||
from searx.result_types import EngineResults
|
from searx.result_types import EngineResults
|
||||||
from searx.utils import parse_duration_string
|
from searx.utils import html_to_text, parse_duration_string
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
from searx.search.processors import OnlineParams
|
from searx.search.processors import OnlineParams
|
||||||
@@ -148,8 +147,8 @@ def response(resp: "SXNG_Response") -> EngineResults:
|
|||||||
res.add(
|
res.add(
|
||||||
res.types.MainResult(
|
res.types.MainResult(
|
||||||
url=result["url"],
|
url=result["url"],
|
||||||
title=html.unescape(result["title"]),
|
title=html_to_text(result["title"]),
|
||||||
content=html.unescape(result["snippet"]),
|
content=html_to_text(result["snippet"]),
|
||||||
thumbnail=result.get("image", {}).get("url") or "",
|
thumbnail=result.get("image", {}).get("url") or "",
|
||||||
publishedDate=published_date,
|
publishedDate=published_date,
|
||||||
)
|
)
|
||||||
@@ -158,7 +157,7 @@ def response(resp: "SXNG_Response") -> EngineResults:
|
|||||||
res.add(
|
res.add(
|
||||||
res.types.Image(
|
res.types.Image(
|
||||||
url=result["url"],
|
url=result["url"],
|
||||||
title=html.unescape(result.get("title")),
|
title=html_to_text(result.get("title")),
|
||||||
img_src=result.get("image", {}).get("url"),
|
img_src=result.get("image", {}).get("url"),
|
||||||
resolution=f"{result['image']['width']}x{result['image']['height']}",
|
resolution=f"{result['image']['width']}x{result['image']['height']}",
|
||||||
thumbnail_src=result.get("props", {}).get("thumbnail", {}).get("url"),
|
thumbnail_src=result.get("props", {}).get("thumbnail", {}).get("url"),
|
||||||
@@ -174,8 +173,8 @@ def response(resp: "SXNG_Response") -> EngineResults:
|
|||||||
{
|
{
|
||||||
"template": "videos.html",
|
"template": "videos.html",
|
||||||
"url": result["url"],
|
"url": result["url"],
|
||||||
"title": html.unescape(result["title"]),
|
"title": html_to_text(result["title"]),
|
||||||
"content": html.unescape(result["snippet"]),
|
"content": html_to_text(result["snippet"]),
|
||||||
"thumbnail": result.get("image", {}).get("url"),
|
"thumbnail": result.get("image", {}).get("url"),
|
||||||
"publishedDate": published_date,
|
"publishedDate": published_date,
|
||||||
"author": result["props"].get("creator_name"),
|
"author": result["props"].get("creator_name"),
|
||||||
|
|||||||
Reference in New Issue
Block a user