0

我去了 Skyscanner API 文档页面,并在语言选择器中选择了“Python (Requests)”。然后我复制了代码片段并将入站和出站日期更改为有效日期(即,比今天晚的日期)。但运行代码后,我得到空白结果。这是为什么?

import requests

url = "https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/pricing/v1.0"

payload = "inboundDate=2020-05-20&cabinClass=business&children=0&infants=0&country=US&currency=USD&locale=en-US&originPlace=SFO-sky&destinationPlace=LHR-sky&outboundDate=2020-05-15&adults=1"
headers = {
    'x-rapidapi-host': "skyscanner-skyscanner-flight-search-v1.p.rapidapi.com",
    'x-rapidapi-key': "MY_API_KEY", # need to fill up a form to get the Key
    'content-type': "application/x-www-form-urlencoded"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

>>> {}
4

1 回答 1

0

您是否检查过该 API 的响应示例?

大多数时候 API 必须返回 True 然后响应空白。

于 2020-03-10T06:54:00.760 回答