我转到Skyscanner API文档page,在语言选择器中选择"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¤cy=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)
>>> {}发布于 2020-03-10 14:54:01
你检查过那个API的响应示例了吗?
大多数情况下,当API必须返回True时,响应也会为空。
https://stackoverflow.com/questions/60611620
复制相似问题