故事的起源于我发现我选课的时候点已选人数那一栏居然可以看到当前课的已选人员,接下来的事就变得简单了,通过对网页的分析,我获取了本学期开设的课的所有链接,根据链接获取了所有选课的人的信息,整合在了一个json文件中。最后在写个简单的查询程序即可查询选课信息。
截至2018年9月6日九点大概四万七千多条数据,运用程序很容易就可以获取每个人的选课信息了,下面话不多说,直接上程序,由于涉及到学生的隐私问题,我把关键的cookies去掉了,如果你是科大的,你可以填补上cookies就可以继续使用本程序了
import requests
from pyquery import PyQuery as pq
import json
url='http://mis.teach.ustc.edu.cn/gradGetDxkc.do'
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36','x-requested-with':'XMLHttpRequest'}
cookies={}
def get_classinfor(classlink,classname,teacher,classplace_time):
curl='http://mis.teach.ustc.edu.cn/'
url=curl+classlink
newhtml=requests.get(url,headers=headers,cookies=cookies).text
subdoc=pq(newhtml)
infor=subdoc('#jcxxtable0 > tr').items()
for each in infor:
data={
'xuehao':each.find('td:nth-child(2)').text(),
'student_name':each.find('td:nth-child(3)').text(),
'yuanxi':each.find('td:nth-child(4)').text(),
'classname':classname,
'teacher':teacher,
'classplace_time':classplace_time
}
with open('information.json','a',encoding='utf-8') as f:
f.write(json.dumps(data,ensure_ascii=False))
f.write(',')
html=requests.get(url,headers=headers,cookies=cookies).text
doc=pq(html)
alllink=doc('#form1 > div.cont-list > table > tr').items()
for link in alllink:
if link.find('td:nth-child(9) > a').attr('href')!=None:
classlink=link.find('td:nth-child(9) > a').attr('href')
classname=link.find('td:nth-child(4)').text()
teacher=link.find('td:nth-child(5)').text()
classplace_time=link.find('td:nth-child(7)').text()
#print(classlink)
get_classinfor(classlink,classname,teacher,classplace_time)
最后上一下我写的查询程序效果图:

You have one of the better web sites.
Thank u
I appreciate the information on your websites.
Many thanks!
Many thanks extremely valuable. Will certainly share site with my friends.
I like this site – its so usefull and helpfull.