0
点赞
收藏
分享

微信扫一扫

kfc门店信息

彭维盛 2022-05-05 阅读 14
python
'''区分动态网页与静态网页:
                查看源代码是否能查找到网页文本信息
'''
import  requests
import json
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/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44'
           }
for i in range(1,4):
    form_data = {
       'cname':'',
        'pid':'',
        'keyword':'重庆',
        'pageIndex':str(i),
        'pageSize':10
    }
    response = requests.post(url=url, headers=headers, data=form_data).text
    response_dict = json.loads(response)
    for item in response_dict['Table1']:
        print(item['storeName'],item['addressDetail'],item['provinceName'],item['cityName'])
    print('第{}页爬取完毕!!!'.format(i))
举报

相关推荐

0 条评论