我去了 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¤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)
>>> {}