HTTP error while getting info of a ticker
See original GitHub issuestock = yf.Ticker("MSFT")
stock_name = stock.info["shortName"]
When I execute this code multiple times (this happens about 100 times a day) I got such an error:
HTTP Error 503: Service Unavailable Traceback (most recent call last): File “bot.py”, line 327, in watchlist_notify stock_name = stock.info[“shortName”] File “/Users/Sepy/dev/stockBot/venv/pythonBot/src/yfinance/yfinance/ticker.py”, line 138, in info return self.get_info() File “/Users/Sepy/dev/stockBot/venv/pythonBot/src/yfinance/yfinance/base.py”, line 416, in get_info self._get_fundamentals(proxy) File “/Users/Sepy/dev/stockBot/venv/pythonBot/src/yfinance/yfinance/base.py”, line 284, in _get_fundamentals holders = _pd.read_html(url) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/util/_decorators.py”, line 296, in wrapper return func(*args, **kwargs) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/html.py”, line 1086, in read_html return _parse( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/html.py”, line 898, in _parse tables = p.parse_tables() File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/html.py”, line 217, in parse_tables tables = self._parse_tables(self._build_doc(), self.match, self.attrs) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/html.py”, line 736, in _build_doc raise e File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/html.py”, line 717, in _build_doc with urlopen(self.io) as f: File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/common.py”, line 137, in urlopen return urllib.request.urlopen(*args, **kwargs) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”, line 222, in urlopen return opener.open(url, data, timeout) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”, line 531, in open response = meth(req, response) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”, line 640, in http_response response = self.parent.error( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”, line 569, in error return self._call_chain(*args) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”, line 502, in _call_chain result = func(*args) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”, line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 503: Service Unavailable
What could be the reasons for the problem?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Related StackOverflow Question
Try to see if the below solve your problem. I had the same issue and it was down to Yahoo blocking me as a scrapper.
https://github.com/ranaroussi/yfinance/issues/445 https://github.com/ranaroussi/yfinance/commit/6a8c637af758ff3de53f2ca3dafb6bf10f1902b9
A 503 Service Unavailable Error is an HTTP response status code indicating that your web server operates properly, but it can’t temporarily handle the request at the moment. This error happen for a wide variety of reasons. Normally, this error can be due to a temporary overloading or maintenance being performed on the server and it is resolved after a period of time or once another thread has been released by web-server application. A 503 service unavailable is a temporary condition and the caller should retry after a reasonable period of time. Also check the http response headers for the description of the 503 error.