updated and added functions

This commit is contained in:
Linus E 2022-04-04 18:57:59 +02:00
parent a2aed53bc8
commit 643c040b32

View File

@ -36,7 +36,26 @@ def get_all_news_by_keyword(keyword, from_date="2000-01-01"): # hard coded will
JSON/dict: dict containing articles
"""
top_headlines = newsapi.get_everything(q=keyword, sources=str_sources, language='en', from_param=from_date)
if(top_headlines["status"] == "ok"):
return top_headlines
else:
return None
def get_top_news_by_keyword(keyword):
"""get top news to keyword
Args:
keyword (String): keyword for search
Returns:
JSON/dict: dict containing articles
"""
top_headlines = newsapi.get_top_headlines(q=keyword, sources=str_sources, language='en')
if(top_headlines["status"] == "ok"):
return top_headlines
else:
return None
def format_article(article):
"""format article for messaging (using markdown syntax)