求助,代码哪里错了。抄的作业跑步起来
import requestsimport json
if __name__ == "__main__":
url = "https://movie.douban.com/j/chart/top_list"
param = {
"type": "24",
"interval_id": "100:90",
"action": "",
"start": "0",
"limit": "20"
}
headers = {
"User - Agent": "Mozilla / 5.0(Windows NT 10.0;Win64;x64)"
" AppleWebKit / 537.36(KHTML, likeGecko) "
"Chrome / 100.0.4896.75Safari / 537.36Edg / 100.0.1185.36"
}
response = requests.get(url=url,params=param,headers=headers)
list_data = response.json()
fp = open("douban.json","w",encoding = "utf-8")
json.dump(list_data,fp=fp,ensure_ascii=False)
print('over!!!')
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: : 0 import requests
import json
if __name__ == "__main__":
url = "https://movie.douban.com/j/chart/top_list"
param = {
"type": "24",
"interval_id": "100:90",
"action": "",
"start": "0",
"limit": "20"
}
headers = {
"User-Agent": "Mozilla / 5.0(Windows NT 10.0;Win64;x64)" # User-Agent 中间不要空格
" AppleWebKit / 537.36(KHTML, likeGecko) "
"Chrome / 100.0.4896.75Safari / 537.36Edg / 100.0.1185.36"
}
response = requests.get(url=url,params=param,headers=headers)
list_data = response.json()
fp = open("douban.json","w",encoding = "utf-8")
json.dump(list_data,fp=fp,ensure_ascii=False)
print('over!!!')
页:
[1]