diff options
author | Hackurei <138650713+Hackurei@users.noreply.github.com> | 2023-10-12 23:29:51 -0600 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2023-10-13 08:16:47 +0200 |
commit | efada7cba22b132233260daf1e53279ece47340c (patch) | |
tree | f806435097ebb0cb196b698861868ad5e5d72008 | |
parent | af071121de85c4694e766356994db6217721e970 (diff) | |
download | searxng-efada7cba22b132233260daf1e53279ece47340c.tar.gz searxng-efada7cba22b132233260daf1e53279ece47340c.zip |
[fix] hackernews keyerror problem
-rw-r--r-- | searx/engines/hackernews.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/searx/engines/hackernews.py b/searx/engines/hackernews.py index 3f07b6e58..4183874f2 100644 --- a/searx/engines/hackernews.py +++ b/searx/engines/hackernews.py @@ -71,17 +71,17 @@ def response(resp): for hit in data["hits"]: object_id = hit["objectID"] - points = hit["points"] or 0 - num_comments = hit["num_comments"] or 0 + points = hit.get("points") or 0 + num_comments = hit.get("num_comments") or 0 metadata = "" if points != 0 or num_comments != 0: metadata = f"{gettext('points')}: {points}" f" | {gettext('comments')}: {num_comments}" results.append( { - "title": hit["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}", - "content": hit["url"] or hit["comment_text"] or hit["story_text"] or "", + "content": hit.get("url") or hit.get("comment_text") or hit.get("story_text") or "", "metadata": metadata, "author": hit["author"], "publishedDate": datetime.utcfromtimestamp(hit["created_at_i"]), |