-1

I do not much experience with APIs, so the answer to this may be obvious to some. I am using the the Skyscanner API from RapidAPI for a project, and whenever I test the endpoint in the RapidAPI API playground, it seems to work just fine. However, when I copy the code (without making any changes) to my IDE, it throws a bunch of errors, particularly a "certificate verify failed" error. Here is the code I used (i replaced the key for the purpose of this post):

  import requests

url = "https://skyscanner44.p.rapidapi.com/search"

querystring = {"adults":"1",
               "origin":"LAX",
               "destination":"DCA",
               "departureDate":"2022-08-01",
               "returnDate":"2022-08-15",
               "cabinClass":"economy",
               "currency":"USD"}

headers = {
    "X-RapidAPI-Key": "XXX",
    "X-RapidAPI-Host": "skyscanner44.p.rapidapi.com"
}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)

Here is the errors it throws:

Traceback (most recent call last):
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
    conn.connect()
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\ssl.py", line 1070, in _create
    self.do_handshake()
  File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

Any help is greatly appreciated!

ahap13
  • 1
  • Does this answer your question? [Scraping: SSL: CERTIFICATE\_VERIFY\_FAILED error for http://en.wikipedia.org](https://stackoverflow.com/questions/50236117/scraping-ssl-certificate-verify-failed-error-for-http-en-wikipedia-org) – esqew Jul 07 '22 at 17:05

1 Answers1

0

The tool is trying to validate the certificate. Try set a more attribute to your requests constructor like

requests.get(url, verify=False)
Franz Kurt
  • 1,020
  • 2
  • 14
  • 14