美文网首页
两种post请求方式

两种post请求方式

作者: 丷菜菜呀 | 来源:发表于2018-12-11 05:45 被阅读0次


    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)

    相关文章

      网友评论

          本文标题:两种post请求方式

          本文链接:https://www.haomeiwen.com/subject/jtgjhqtx.html