payload请求:
refer =f'http://flights.ctrip.com/itinerary/oneway/{dcity}-{acity}?date={date}'
self.headers = {
'User-Agent':'Mozilla/5.0(Windows NT10.0;WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3610.2 Safari/537.36',
'Referer': refer,
'Content-Type':'application/json;charset=utf-8',
}
self.payload = {
"flightWay":"Oneway",
"classType":"ALL",
"hasChild":False,
"hasBaby":False,
"searchIndex":1,
"airportParams":[
{"dcity": dcity_code,
"acity": acity_code,
# "dcityname": dcity,
# "acityname": acity,
"date": date,
"dcityid": dcity_id,
"acityid": acity_id
}
]}
res = requests.post(url=self.url,headers=self.headers,data=json.dumps(self.payload))
参数在主体中
refer =f'http://trains.ctrip.com/TrainBooking/Search.aspx?from={d}&to={a}&day={date}'
self.headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3610.2 Safari/537.36',
'Referer': refer,
}
value = {
"DepartureCityName":from_station,
"ArrivalCityName":to_station,
"DepartureDate":date,
}
self.postdata = {
'value': json.dumps(value)
}
res = requests.post(self.url,headers=self.headers,data=self.postdata)
网友评论