马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import requests
import json
location=input('输入你想要查询的地名:')
url='http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
param={'cname': '','pid':'', 'keyword':location,'pageIndex':'1','pageSize': '10'}
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 SLBrowser/8.0.1.4031 SLBChan/105'}
response=requests.post(url=url,data=param,headers=headers)
list=response.json()
numbers=int(list[0][0])
pages=numbers/10
for page in range(1,pages+1):
param = {'cname': '', 'pid': '', 'keyword': location, 'pageIndex': page, 'pageSize': '10'}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 SLBrowser/8.0.1.4031 SLBChan/105'}
response = requests.post(url=url, data=param, headers=headers)
list = response.json()
for i in list['Table1']:
print(i['cityName']+i['storeName'],i['addressDetail'])
|