news working

This commit is contained in:
Rripped
2022-03-29 12:20:58 +02:00
parent 4afd1ab87b
commit 4bd53c0116
2 changed files with 11 additions and 8 deletions

View File

@@ -14,7 +14,6 @@ import requests
from newsapi import NewsApiClient
from dotenv import load_dotenv
import urllib.parse as urlparse
load_dotenv()
@@ -34,8 +33,7 @@ def get_top_news_by_keyword(keyword):
Returns:
JSON/dict: dict containing articles
"""
keyword_url = urlparse.quote(keyword)
top_headlines = newsapi.get_top_headlines(q=keyword_url, sources=str_sources, language='en')
top_headlines = newsapi.get_everything(q=keyword, sources=str_sources, language='en')
return top_headlines
def format_article(article):