网络爬虫作业
import requests
import json
try:
r=requests.get('https://edu.cnblogs.com/Homework/GetAnswers?homeworkId=2420&_=1543716986749')
r.raise_for_status()
r.text
except:
print('网页无法打开')
json_data=json.loads(r.text)['data']
for a in json_data:
date+=str(a['StudentNo'])+','+a['RealName']+','+a['DateAdded'].replace('T',' ')+','+a['Title']+','+a['Url']+'\n'
with open('E:\hwlist.csv','w')as f:
f.write(date)


浙公网安备 33010602011771号