fetch("https://can.ctrip.com/api/product/hotelfilter", { "headers": { "accept": "application/json, text/javascript, */*; q=0.01", "accept-language": "zh-CN,zh;q=0.9", "authorization": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3MDQxMiIsInVzZXJuYW1lIjoiWFJUWDA5MjUiLCJ1dWlkIjoiTG9naW5jMTQ4M2NiNy1lMDA0LTQyMWMtYWM2MS04YjVmOGYyYjZiYTciLCJyb2xlTmFtZXMiOlsiUk9MRV9BRE1JTiJdLCJleHAiOjE2NzQwMzU4MDZ9.4uxlgs29BIVP-KKlyHtOkTV-9Dv7muB65MCnA4nstPaVRwqHhT3Imw-8b8eHUdKZhY-l1Z7OHxsw2jAS2NWShQ", "content-type": "application/json", "sec-ch-ua": "\"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "syslng": "zhCN", "x-requested-with": "XMLHttpRequest" }, "referrer": "https://can.ctrip.com/index", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{\"cityid\":\"2\",\"countryid\":\"1\",\"currency\":\"CNY\"}", "method": "POST", "mode": "cors", "credentials": "include" }); 转成 python 代码
时间: 2023-02-12 12:02:23 浏览: 166
import requests
url = "https://can.ctrip.com/api/product/hotelfilter"
headers = {
"accept": "application/json, text/javascript, */*; q=0.01",
"accept-language": "zh-CN,zh;q=0.9",
"authorization": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3MDQxMiIsInVzZXJuYW1lIjoiWFJUWDA5MjUiLCJ1dWlkIjoiTG9naW5jMTQ4M2NiNy1lMDA0LTQyMWMtYWM2MS04YjVmOGYyYjZiYTciLCJyb2xlTmFtZXMiOlsiUk9MRV9BRE1JTiJdLCJleHAiOjE2NzQwMzU4MDZ9.4uxlgs29BIVP-KKlyHtOkTV-9Dv7muB65MCnA4nstPaVRwqHhT3Imw-8b8eHUdKZhY-l1Z7OHxsw2jAS2NWShQ",
"content-type": "application/json",
"sec-ch-ua": "\"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"syslng": "zhCN",
"x-requested-with": "XMLHttpRequest"
}
data = {"cityid":"2","countryid":"1","currency":"CNY"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
阅读全文