import requests
肯德基餐厅查询: http://www.kfc.com.cn/kfccda/storelist/index.aspx
**分析:**
数据为动态加载数据
通过全局抓包工具的全局搜索捕获动态加载数据
```python
url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Mobile Safari/537.36 Edg/89.0.774.54'
}
data = {
'cname': '',
'pid': '',
'keyword': '北京',
'pageIndex': '1',
'pageSize': '10',
}
# 参数:data是用来实现参数动态化,等同于ge方法中的params参数的作用
response = requests.post(url=url,headers=headers,data=data)
page_text = response.json()
# print(page_text)
for dic in page_text['Table1']:
pos = dic['addressDetail']
print(pos)