File size: 494 Bytes
415516b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from api_keys import newsdata_api
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