Hi, I would like to get information from Wikipedia articles and I am testing the connection to Wikipedia.
I am running Python 3.6.2 on Windows 10. I get certificate errors for all pages with https. Any suggestions are welcome! Here my code: import requests, bs4 from bs4 import BeautifulSoup res = requests.get('https://en.wikipedia.org/wiki/Stethoscope') type(res) res.status_code == requests.codes.ok wiki = bs4.BeautifulSoup(res.text) type(wiki) len(res.text) print(res.text[:250]) Here the error message: Traceback (most recent call last): File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen chunked=chunked) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request self._validate_conn(conn) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn conn.connect() File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connection.py", line 326, in connect ssl_context=context) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 401, in wrap_socket _context=self, _session=session) File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 808, in __init__ self.do_handshake() File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 1061, in do_handshake self._sslobj.do_handshake() File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 683, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 440, in send timeout=timeout File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen _stacktrace=sys.exc_info()[2]) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\util\retry.py", line 388, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /wiki/Stethoscope (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "web_1.py", line 3, in <module> res = requests.get('https://en.wikipedia.org/wiki/Stethoscope') File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 508, in request resp = self.send(prep, **send_kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 618, in send r = adapter.send(request, **kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 506, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /wiki/Stethoscope (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),)) -- https://mail.python.org/mailman/listinfo/python-list