Unable to access wikipedia API due to SSL-certificate error
Question: 
    import requests
    
    spiders = requests.get('https://en.wikipedia.org/w/api.php')
    print(spiders)
    

With above code I am getting following error:

    
    
    Traceback (most recent call last):
      File "C:\Python\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 554, in urlopen
        self._prepare_proxy(conn)
      File "C:\Python\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 750, in _prepare_proxy
        conn.connect()
      File "C:\Python\lib\site-packages\requests\packages\urllib3\connection.py", line 252, in connect
        ssl_version=resolved_ssl_version)
      File "C:\Python\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 305, in ssl_wrap_socket
        return context.wrap_socket(sock, server_hostname=server_hostname)
      File "C:\Python\lib\ssl.py", line 376, in wrap_socket
        _context=self)
    
      File "C:\Python\lib\ssl.py", line 747, in __init__
        self.do_handshake()
      File "C:\Python\lib\ssl.py", line 983, in do_handshake
        self._sslobj.do_handshake()
      File "C:\Python\lib\ssl.py", line 628, in do_handshake
        self._sslobj.do_handshake()
    ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
    

Using a certificate I still get an error:

    
    
    import requests
    
    spiders = requests.get('https://en.wikipedia.org/w/api.php',cert = 'c:\python\lib\site-packages\certifi\cacert.pem',verify = True)
    print(spiders)
    
    Traceback (most recent call last):
      File "C:/Python/Files/3.py", line 3, in <module>
        spiders = requests.get('https://en.wikipedia.org/w/api.php',cert = 'c:\python\lib\site-packages\certifi\cacert.pem',verify = True)
      File "C:\Python\lib\site-packages\requests\api.py", line 67, in get
        return request('get', url, params=params, **kwargs)
      File "C:\Python\lib\site-packages\requests\api.py", line 53, in request
        return session.request(method=method, url=url, **kwargs)
      File "C:\Python\lib\site-packages\requests\sessions.py", line 468, in request
        resp = self.send(prep, **send_kwargs)
      File "C:\Python\lib\site-packages\requests\sessions.py", line 576, in send
        r = adapter.send(request, **kwargs)
      File "C:\Python\lib\site-packages\requests\adapters.py", line 447, in send
        raise SSLError(e, request=request)
    requests.exceptions.SSLError: [SSL] PEM lib (_ssl.c:2824)
    

Even when I have followed some tutorial verbatim I have encountered this issue
when the instructor would have access w/o issue. Any ideas?


Answer: u can ignore SSL like this:

    
    
    import requests
    
    spiders = requests.get('https://en.wikipedia.org/w/api.php',verify = False)
    print(spiders)
    

other solution:

    
    
    from urllib.request import Request, urlopen
    rq = Request('https://en.wikipedia.org/w/api.php')
    response = urlopen(rq).read()
    

