python爬虫,接口是post请求,参数是request payload 的形式,如何传参
解决post payload美团问题,
特别注意json转化
# encoding: utf-8
#url解析
import json
import requests
headers = {
'Content-Type': 'application/json'
}
data = {
"checkInDate": "2020-04-17",
"checkOutDate": "2020-04-18",
"cityId": "184",
"clientType": "touch",
"clientVersion": "999.9",
"goodsId": 633543819,
"goodsType": 1,
"gpsCityId": "184",
"lat": "34.240458",
"lng": "118.853467",
"noPersistent": 0,
"partnerId": 261471,
"requestType": 0,
"poiId": "42367975",
"roomId": 923963218,
"userid": -1
# "propagateData": {"hap_key":0,"price":"D+GukTqN8RF+H6Tf9AY6rw==","traceId":"6706722068678919169","goodsStatus":0,"realGoodsStatus":"4ppBvaihWoVn/5v4JOOPYwY0v8sZt6PPZtnfy6a4Tgw=","conId":0,"gs":"7RyF2M/q4PA6SSMeFT7l3g==","contentTransparent":0}
}
# 传json格式的参数
jdata = json.dumps(data)
url = 'https://ihotel.meituan.com/group/v1/yf/productDetail?_token=eJyrVi/yTFG3UlBX11FQLykGsgxNLcwNDUyNTU2MjC2AgslIomZw0aSiMBegcHQsmB0EZ3rCWLkhMFY2nJUIZ5XAWcWZ6Xkg+1O9yl0cwcDVVr0WAJL6JMU=&uuid=&iuuid=BDBBEFF82F963357D26CA0E58C3BD6C512868DFF22FAFFCEE9820F513311A6C8&userid=&utm_medium=touch&version_name=999.9&platformid=1'
response = requests.post(url=url, data=jdata, headers=headers)
print(response.json())