import urllib.request
import urllib.parse
url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname'
city = input('请输入你要查找的城市:')
Index = input('请输入你要查找第几页:')
Size = input('请输入你要查询多少个:')
#pageIndex = int(input('请输入你要查询的页数:'))
form_data={
'cname': city,
'pid': '',
'pageIndex': Index,
'pageSize': Size,
}
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',
}
request = urllib.request.Request(url = url,headers = headers)
form_data = urllib.parse.urlencode(form_data).encode()
response = urllib.request.urlopen(request,data=form_data)
print(response.read().decode())