Open pythonian1027 opened 1 year ago
In regards to
"'function get_earnings_history -> Exception: "string indices must be integers"',"
This looks to be an issue with change Yahoo made to its API.
If you run the function from stock_info.py:
def get_earnings_history(ticker):
url = "https://finance.yahoo.com/calendar/earnings?symbol=" + ticker
result = _parse_earnings_json(url)
return result["context"]["dispatcher"]["stores"]["ScreenerResultsStore"]#["results"]["rows"]
the ["stores"]
key no longer returns a dict with ["ScreenerResultsStore"] key but a string of 900,000+ characters.
I'm assuming Yahoo blocked this due to their rollout of Yahoo Finance Plus Essentials which is $30/mo
@dancassin any luck for you? i am facing similar issues with get_company_info function
ticker_symbol = "ABFRL.NS" company_info = si.get_company_info(ticker_symbol) print(company_info)
the following error i am getting
_in get_company_info json_info = jsoninfo["assetProfile"] TypeError: string indices must be integers
I don't believe there's a way to resolve this since it is built on Yahoo! giving you the information for free. Now that the info isn't free, there's no data to extract.
@dancassin thank you for replying quickly i have managed it with yfinance for now
OS: Windows 10 Python version: 3.7
ticker: 'AAPL' when applicable Exceptions per method call:
'function get_cash_flow -> Exception: "string indices must be integers"', 'function get_company_info -> Exception: "string indices must be integers"',
'function get_earnings_for_date -> Exception: "TypeError: string indices must be integers"', (case: get_earnings_for_date('02/08/2021')) 'function get_earnings_in_date_range -> returns emptyf (case: get_earnings_in_date_range('02/08/2021', '02/12/2021')) 'function get_earnings_history -> Exception: "string indices must be integers"', 'function get_financials -> Exception: "string indices must be integers"',
'function get_income_statement -> Exception: "string indices must be integers"', 'function get_next_earnings_date -> Exception: "string indices must be integers"', 'function get_top_crypto -> Exception: "KeyError: '1 Day Chart'"', 'function get_splits -> Exception: "\'events\'"', 'function get_stats_valuation -> Exception: "list index out of range"', , works with other tickers (e.g. NFLX) 'function tickers_ftse100 -> Exception: "AttributeError: 'DataFrame' object has no attribute 'EPIC'"', 'function tickers_ftse250 -> Exception: "ValueError: Length mismatch: Expected axis has 3 elements, new values have 2 elements"',