使用json库的报错
这是代码import requests
import json
#1,指定url
url = 'http://www.kfc.com.cn/kfccda'
#2,给定参数
param={
'cname': '',
'pid': '',
'keyword': '北京',
'pageIndex': '1',
'pageSize': '10',
}
#3,UA伪装
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70'
}
#4,发起请求
response = requests.post(url,data=param,headers=headers)
dic_obj = response.json()
#持续化存储
filename = '北京肯德基地址' +'.json'
with open(filename,'w',encoding='utf-8') as fp:
json.dump(dic_obj,fp=fp,ensure_ascii=False)
print('over!!!')
print(response)
<Response >
{:10_293:} kogawananari 发表于 2021-7-20 15:38
print(response)
OK,我改好了,谢谢你
页:
[1]