mirror of
https://github.com/searxng/searxng.git
synced 2025-11-23 06:53:08 -05:00
[fix] hackernews contains HTML escape codes
This commit is contained in:
parent
b9b46431be
commit
7a1b959646
@ -6,6 +6,7 @@ from urllib.parse import urlencode
|
|||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
from flask_babel import gettext
|
from flask_babel import gettext
|
||||||
|
from searx.utils import html_to_text
|
||||||
|
|
||||||
# Engine metadata
|
# Engine metadata
|
||||||
about = {
|
about = {
|
||||||
@ -75,6 +76,7 @@ def response(resp):
|
|||||||
object_id = hit["objectID"]
|
object_id = hit["objectID"]
|
||||||
points = hit.get("points") or 0
|
points = hit.get("points") or 0
|
||||||
num_comments = hit.get("num_comments") or 0
|
num_comments = hit.get("num_comments") or 0
|
||||||
|
content = hit.get("url") or html_to_text(hit.get("comment_text")) or html_to_text(hit.get("story_text"))
|
||||||
|
|
||||||
metadata = ""
|
metadata = ""
|
||||||
if points != 0 or num_comments != 0:
|
if points != 0 or num_comments != 0:
|
||||||
@ -83,7 +85,7 @@ def response(resp):
|
|||||||
{
|
{
|
||||||
"title": hit.get("title") or f"{gettext('author')}: {hit['author']}",
|
"title": hit.get("title") or f"{gettext('author')}: {hit['author']}",
|
||||||
"url": f"https://news.ycombinator.com/item?id={object_id}",
|
"url": f"https://news.ycombinator.com/item?id={object_id}",
|
||||||
"content": hit.get("url") or hit.get("comment_text") or hit.get("story_text") or "",
|
"content": content,
|
||||||
"metadata": metadata,
|
"metadata": metadata,
|
||||||
"author": hit["author"],
|
"author": hit["author"],
|
||||||
"publishedDate": datetime.fromtimestamp(hit["created_at_i"]),
|
"publishedDate": datetime.fromtimestamp(hit["created_at_i"]),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user