Python简单Post例子

2022-01-20 16:35:01 浏览数 (1)

代码语言:javascript复制
import requests
import json

url = 'https://www.vivo.com/store/shops'
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
}
From_data = {
        "province": "山东省",
        "city": "济南市",
        "searchType": "0",
        "latitude": "36.66199",
        "longitude": "117.51855",
        "minRadius": "30",
        "from": "1"
}
response = requests.post(url=url, headers=headers, data=From_data)
str_json = json.loads(response.text)
print(json.dumps(str_json, sort_keys=True, indent=4, separators=(',', ':'), ensure_ascii=False))

Post Json格式数据:

代码语言:javascript复制
import requests

url = 'https://demo.xxx.com/Sacrifice/insertSacrifice'
data = {
    "sacrificeFlower": "2",
    "sacrificeVenue": "济南解放纪念馆",
    "sacrificeTitle": "2021庆崛起",
    "sacrificeName": "xxx",
    "sacrificeValues": "缅怀先烈,向革命烈士致敬,勿忘国耻。"
}
r = requests.post(url=url, json=data)
print(r.text)

版权属于:kenvie

本文链接:https://cloud.tencent.com/developer/article/1937753

商业转载请联系作者获得授权,非商业转载请注明出处。

0 人点赞