网络爬虫

import requests
import json
r=requests.get("https://edu.cnblogs.com/Homework/GetAnswers?homeworkId=2420&_=1543846454903")
data=json.loads(r.text)['data']  
info="" 
for a in data:
    info += str(a['StudentNo'])+','+a['RealName']+','+a['Title']+','+a['DateAdded']+','+a['Url']+'\n'        
with open('hwlist.csv','w')as f:
    f.write(info)

posted on 2018-12-04 15:06  李念慈  阅读(121)  评论(0编辑  收藏  举报