看了很多大佬的作业,也参考了很多网上的资料,终于写出来了,虽然有点不对,但是也弄出点雏形,请老师和各位大佬手下留情。第二题实在不会……
import requests import json r=requests.get("https://edu.cnblogs.com/Homework/GetAnswers?homeworkId=2420&_=1543752749008") if r.status_code==200: pass else: print('false') r.encoding='utf-8' json_data=json.loads(r.text) result='' for i in json_data['data']: u=str(i['StudentNo'])+','+str(i['RealName'])+','+str(i['Title'])+','+str(i['DateAdded'].replace('T',' '))+','+str(i['Url']) result=result+u+'\n' print(u) f=open('hwlist.csv','w') f.write(result) f.close()
浙公网安备 33010602011771号