updated and added functions
This commit is contained in:
parent
a2aed53bc8
commit
643c040b32
@ -36,7 +36,26 @@ def get_all_news_by_keyword(keyword, from_date="2000-01-01"): # hard coded will
|
|||||||
JSON/dict: dict containing articles
|
JSON/dict: dict containing articles
|
||||||
"""
|
"""
|
||||||
top_headlines = newsapi.get_everything(q=keyword, sources=str_sources, language='en', from_param=from_date)
|
top_headlines = newsapi.get_everything(q=keyword, sources=str_sources, language='en', from_param=from_date)
|
||||||
return top_headlines
|
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):
|
def format_article(article):
|
||||||
"""format article for messaging (using markdown syntax)
|
"""format article for messaging (using markdown syntax)
|
||||||
|
Loading…
Reference in New Issue
Block a user