import requests import json url="https://edu.cnblogs.com/Homework/GetAnswers?homeworkId=2420&_=1543752749008" r=requests.get(url) if r.status_code==200: pass else: print(‘Error‘) json_data=json.loads(r.text) result=‘‘ for item in json_data[‘data‘]: u=str(item[‘StudentNo‘])+‘,‘+str(item[‘RealName‘])+‘,‘+str(item[‘Title‘])+‘,‘+str(item[‘DateAdded‘].replace(‘T‘,‘ ‘))+‘,‘+str(item[‘Url‘]) result=result+u+‘\n‘ print(u) with open(‘hwlist.csv‘,"w") as f: f.write(result)
结果如下:
原文:https://www.cnblogs.com/Huangyixin0802/p/10061300.html