ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
12.92k stars 2.29k forks source link

HTML5Lib Exception #323

Closed aoberai closed 1 year ago

aoberai commented 4 years ago

Every so often, I am getting the following error:

File "/Users/adityaoberai/Programming/Python/StockPriceRetriever/yf_extender.py", line 8, in get_ticker_symbol
    return ticker.get_info()['symbol']
  File "/Users/adityaoberai/Programming/Python/StockPriceRetriever/venv/lib/python3.8/site-packages/yfinance/base.py", line 415, in get_info
    self._get_fundamentals(proxy)
  File "/Users/adityaoberai/Programming/Python/StockPriceRetriever/venv/lib/python3.8/site-packages/yfinance/base.py", line 284, in _get_fundamentals
    holders = _pd.read_html(url)
  File "/Users/adityaoberai/Programming/Python/StockPriceRetriever/venv/lib/python3.8/site-packages/pandas/io/html.py", line 1085, in read_html
    return _parse(
  File "/Users/adityaoberai/Programming/Python/StockPriceRetriever/venv/lib/python3.8/site-packages/pandas/io/html.py", line 891, in _parse
    parser = _parser_dispatch(flav)
  File "/Users/adityaoberai/Programming/Python/StockPriceRetriever/venv/lib/python3.8/site-packages/pandas/io/html.py", line 840, in _parser_dispatch
    raise ImportError("html5lib not found, please install it")
ImportError: html5lib not found, please install it'

I have already installed Html5lib...

Has anyone else had this issue and has anyone found a solution?

rodrigobercini commented 4 years ago

Could you provide an example of your code? Is there any specific condition that triggers this issue?

castis commented 3 years ago

This is caused by pandas attempting to fetch a list of institutional holders when yahoo doesnt show any.

import yfinance
result = yfinance.Ticker('AACQU')
result.info # the line that actually expresses the error

Good: https://finance.yahoo.com/quote/AAPL/holders Bad: https://finance.yahoo.com/quote/AACQU/holders

I have bypassed the error this way: https://github.com/castis/yfinance/commit/0a1eb6f4886e2cde6ed24cbebbd6b0d167561bc5