import requests
#UA伪装:将对应的User-Agent封装到一个字典中
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.48'
}
#指定url
url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
#处理url携带的参数:封装到字典中
param = {
'cname': '',
'pid':'',
'keyword': '广州',
'pageIndex': 2,
'pageSize': 10
}
#对指定url发起的请求对应的url是携带参数的,并且请求过程中处理了参数
response = requests.get(url=url,params=param,headers=headers)
list_data = response.text
print(list_data)
print('爬取结束')