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