HTTP error while getting info of a ticker

See original GitHub issue
stock = 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:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
beglitiscommented, Jan 20, 2021

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

0reactions
linehammercommented, Jun 14, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python yfinance HTTPError: HTTP Error 404: Not Found
I have looked into changing my header and session information, but can't seem to figure it out. python · http-status-code-404 · yfinance ·...
Read more >
HTTP Status Codes: All 63 explained
HTTP status codes are three-digit responses from the server to the browser-side request. Everyone has probably gotten the classic 404 page-not-found error.
Read more >
Update ticket tags through HTTP target extension (getting ...
Hi all, I have been trying to add tags randomly to some tickets. I happily found this post:...
Read more >
Can't open a ticket with error HTTP ERROR 500
Please check the error logs on your server for a more specific error message, which may give a clue to why this is...
Read more >
Errors | HTTP API | commercetools Composable Commerce
Common HTTP error codes returned by the commercetools Composable Commerce APIs and their meaning. Error responses have the same overall structure across the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found