import requests
import json
headers = {
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Mobile Safari/537.36 Edg/96.0.1054.29"}
url ="http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword"
if __name__ == '__main__':
keyword= input('请输入城市:')
formdata ={
"cname":"" ,
"pid":"" ,
"keyword": keyword,
"pageIndex": "1",
"pageSize": "10"
}
response = requests.post(url=url,data=formdata,headers=headers)
list_data = response.json()
with open('./肯德基地址.txt','w',encoding='utf-8')as fp:
fp.write(str(list_data))
print('end')
爬虫POST请求——肯德基地址爬取
最新推荐文章于 2022-07-23 20:24:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)