mqtran01/python-yahoofinance

TypeError: 'NoneType' object is not subscriptable

Opened this issue · 0 comments

Thanks for this project! Not sure if it is still maintained, but fetching the data currently fails in some case
IncomeStatement

>>> from yahoofinance import IncomeStatement
>>> req = IncomeStatement('AAPL')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.venv/lib/python3.8/site-packages/yahoofinance/incomestatement.py", line 72, in __init__
    fin_data = self._fetch_quote_summary(url)
  File "/.venv/lib/python3.8/site-packages/yahoofinance/interfaces.py", line 54, in _fetch_quote_summary
    json_script = json.loads(re.search(r"root.App.main\s+=\s+(\{.*\})",soup_script)[1])
TypeError: 'NoneType' object is not subscriptable

CashFlow

>>> from yahoofinance import CashFlow
>>> req = CashFlow('AAPL')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.venv/lib/python3.8/site-packages/yahoofinance/cashflow.py", line 70, in __init__
    fin_data = self._fetch_quote_summary(url)
  File "/.venv/lib/python3.8/site-packages/yahoofinance/interfaces.py", line 54, in _fetch_quote_summary
    json_script = json.loads(re.search(r"root.App.main\s+=\s+(\{.*\})",soup_script)[1])
TypeError: 'NoneType' object is not subscriptable

Based on the stacktrace I'd guess yahoo has changed some internal content on their website.

Anyhow, enjoy the holidays!