-3

How do I use the yahoo finance API to get the day's DJIA open each day? when I use

import yahoo_finance
dji = Share('dji')
DJIA = dji.get_open()
print(DJIA)

it gives error <urlopen error [Errno 11001] getaddrinfo failed> on the second line

Tuor
  • 875
  • 1
  • 8
  • 32

1 Answers1

0

If you are using the yfinance package, then you can get the last day's open this way.

import yfinance as yf
data = yf.download(tickers = "dji", interval = "1d", period = "1d")
print(data["Open"][0])
abhigdeal
  • 162
  • 3
  • 9
  • 1) why did I get `[*********************100%***********************] 1 of 1 completed` before the number? 2) it gave a different number than just checking up today's DJI open in the [Yahoo! Finance website](https://finance.yahoo.com/quote/%5EDJI/) – Tuor Apr 12 '20 at 14:51