import urllib.request
import urllib.parse
cname = input('请输入要查询的城市:')
post_url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname'
data = {
'cname': cname,
'pid': '',
'pageIndex': '1',
'pageSize': '10',
}
data = urllib.parse.urlencode(data).encode('utf8')
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
}
request = urllib.request.Request(post_url, headers=headers)
response = urllib.request.urlopen(request, data=data)
print(response.read().decode('utf8'))
urllib-post
最新推荐文章于 2022-08-18 18:59:07 发布