Python将Post返回的数据进行简单解析

2022-01-20 16:31:14 浏览数 (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)
# print(response.text)
json_data = json.loads(response.text)
list_data = json_data['data']['stores']
# print(list_data)
for data in list_data:
    print('店名:'   data['storeName'])
    print('地址:'   data['address'])
    print('==========================')

版权属于:kenvie

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

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

0 人点赞