requests实战之肯德基餐厅查询位置爬取
作者:互联网
requests实战之肯德基餐厅查询位置爬取
在这里插入代码片import requests
if __name__=="__main__":
url = 'http://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/80.0.3987.163 Safari/537.36'
}
kw = input("输入地名")
data={
'cname':'',
'pid':'',
'keyword':kw,
'pageIndex':'1',
'pageSize':'10',
}
response = requests.post(url=url,headers=headers,data=data)
response = response.text
fileName = kw+'.json'
with open(fileName,'w',encoding='utf-8') as fp:
fp.write(response)
print("over...")
标签:__,url,爬取,kw,肯德基,requests,data,response 来源: https://blog.csdn.net/qq_45753992/article/details/113735989