mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-07-22 06:01:40 +00:00
#12 news now prints regardless of how many items api returns.
This commit is contained in:
@@ -40,14 +40,15 @@ def stockNews(ticker):
|
||||
print("Gather News on " + ticker)
|
||||
|
||||
newsLink = f"https://api.iextrading.com/1.0/stock/{ticker}/news/last/5"
|
||||
|
||||
print(newsLink)
|
||||
with urllib.request.urlopen(newsLink) as url:
|
||||
data = json.loads(url.read().decode())
|
||||
|
||||
news = {"link": [], "title": []}
|
||||
for i in range(3):
|
||||
for i in range(len(data)):
|
||||
news["link"].append(data[i]["url"])
|
||||
news["title"].append(data[i]["headline"])
|
||||
print(i)
|
||||
return news
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user