点击查看代码
import requests
# url='https://www.kfc.com.cn/kfccda/storelist/index.aspx'
url = 'https://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
}
for i in range(1, 9):
data = {
"cname": "北京",
"pid": "",
"keyword": "北京",
"pageIndex": str(i),
"pageSize": "10"
}
response = requests.post(url, headers=headers, data=data)
res_json = response.json()
for i in res_json['Table1']:
print(i['storeName'], i['addressDetail'])