#coding:utf-8
import requests
import re
username=
raw_input (
'学号:' )
password=
raw_input (
'密码' )
url=
'http://wlsy.xidian.edu.cn/PhyEws/default.aspx'
s=requests.session()
r=s.get(url,
timeout =
2 ).content
key=re.compile(
' ' )
VIEWSTATE=(re.search(key,r)).group(
1 )
key=re.compile(
' ' ,re.S)
VIEWSTATEGENERATOR=(re.search(key,r)).group(
1 )
key=re.compile(
' ' ,re.S)
EVENTVALIDATION=(re.search(key,r)).group(
1 )
headers={
'User-Agent' :
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0' ,
'Referer' :
'http://wlsy.xidian.edu.cn/PhyEws/default.aspx'
}
data={
'__EVENTTARGET' :
'' ,
'__EVENTARGUMENT' :
'' ,
'__VIEWSTATE' :VIEWSTATE,
'__VIEWSTATEGENERATOR' :VIEWSTATEGENERATOR,
'__EVENTVALIDATION' :EVENTVALIDATION,
'login1$StuLoginID' :username,
'login1$StuPassword' :password,
'login1$UserRole' :
'Student' ,
'login1$btnLogin.x' :
'30' ,
'login1$btnLogin.y' :
'7'
}
while 1 :
try :
s=requests.session()
r=s.post(url,
headers =headers,
data =data,
timeout =
2 )
r=s.get(
'http://wlsy.xidian.edu.cn/PhyEws/student/select.aspx' ,
timeout =
2 ).content
break
except :
pass
r=r.decode(
'gb2312' )
k=re.compile(
'(.*?) (.*?) (.*?) (.*?) (.*?) (.*?) (.*?) (.*?) ',re.S)
items=re.finditer(k,r)
for item
in items:
print item.group(
1 )+
'
' +item.group(
2 )+
',' +item.group(
3 )+
',' +item.group(
4 )+
',' +item.group(
5 )+
',' +item.group(
6 )+
',' +item.group(
7 )+
',' +item.group(
8 )+
'---------------------------------
'