atreadw1492 / yahoo_fin

Scrape stock price history from new (Spring 2017) Yahoo Finance layout
MIT License
285 stars 125 forks source link

Cant get ticker from tickers_sp500() #78

Open EduardoLoz12 opened 2 years ago

EduardoLoz12 commented 2 years ago

Hello, so i've been trying to fix this for some time but i can't get it done. I can use the get_data(), tickers_nasdaq() but tickers_sp500() is not working for me. It give's me this error.

Traceback (most recent call last): File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 1348, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1276, in request self._send_request(method, url, body, headers, encode_chunked) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1322, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1271, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1031, in _send_output self.send(msg) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 969, in send self.connect() File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1448, in connect self.sock = self._context.wrap_socket(self.sock, File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 512, in wrap_socket return self.sslsocket_class._create( File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1070, in _create self.do_handshake() File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1341, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\E.Lozada\AppData\Roaming\JetBrains\PyCharmCE2021.2\scratches\scratch.py", line 3, in a=si.tickers_sp500() File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\yahoo_fin\stock_info.py", line 129, in tickers_sp500 sp500 = pd.read_html("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies")[0] File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\pandas\util_decorators.py", line 311, in wrapper return func(*args, *kwargs) File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\pandas\io\html.py", line 1098, in read_html return _parse( File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\pandas\io\html.py", line 906, in _parse tables = p.parse_tables() File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\pandas\io\html.py", line 222, in parse_tables tables = self._parse_tables(self._build_doc(), self.match, self.attrs) File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\pandas\io\html.py", line 745, in _build_doc raise e File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\pandas\io\html.py", line 726, in _build_doc with urlopen(self.io) as f: File "C:\Users\E.Lozada\PycharmProjects\CryptoRobot\venv\lib\site-packages\pandas\io\common.py", line 212, in urlopen return urllib.request.urlopen(args, *kwargs) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen return opener.open(url, data, timeout) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 519, in open response = self._open(req, data) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 536, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain result = func(args) File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 1391, in https_open return self.do_open(http.client.HTTPSConnection, req, File "C:\Users\E.Lozada\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 1351, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)>

How can i fix this "CertificateVerify Failed" error?