workaround for connection problems
This commit is contained in:
@@ -6,6 +6,7 @@ __date__ = "15.03.2022"
|
||||
__version__ = "0.0.1"
|
||||
__license__ = "None"
|
||||
|
||||
from ast import parse
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
@@ -13,6 +14,7 @@ import requests
|
||||
|
||||
from newsapi import NewsApiClient
|
||||
from dotenv import load_dotenv
|
||||
import urllib.parse as urlparse
|
||||
|
||||
load_dotenv()
|
||||
|
||||
@@ -31,8 +33,9 @@ def get_top_news_by_keyword(keyword):
|
||||
|
||||
Returns:
|
||||
JSON/dict: dict containing articles
|
||||
"""
|
||||
top_headlines = newsapi.get_top_headlines(q=keyword, sources=str_sources, language='en')
|
||||
"""
|
||||
keyword_url = urlparse.quote(keyword)
|
||||
top_headlines = newsapi.get_top_headlines(q=keyword_url, sources=str_sources, language='en')
|
||||
return top_headlines
|
||||
|
||||
def format_article(article):
|
||||
|
Reference in New Issue
Block a user