financial_news_fast_inference / newsdata_caller.py
Andreagus's picture
Update newsdata_caller.py
fc51fd6 verified
raw
history blame
460 Bytes
import requests
from streamlit import secrets
newsdata_api = secrets["newsdata_api"]
def get_newsdata(company):
newsdata_list = []
url = f"https://newsdata.io/api/1/news?apikey={newsdata_api}&q={company}&language=en"
headers = {"accept": "application/json"}
r = requests.request("GET", url, headers=headers)
data = r.json()
for article in data['results']:
newsdata_list.append(article['title'])
return newsdata_list