python获取天津理工大学教务处的最新成绩 天津理工大学成绩查询

import httplib
import sys
import time

id = "20101974"
password = "*********"

msg ="loginType=2&username=%s&name=%s&jwydm=&password=%s&pswd=%s&jwypswd=&image.x=30&image.y=5"% (id, id, password, password)

def get(s):
out=''
state =False

for ch ins:
python获取天津理工大学教务处的最新成绩 天津理工大学成绩查询
if ch == '<':
state = True
continue
elif ch == '>':
state = False
continue
if state == True:
continue
else:
out += ch
returnout

def getgpa(x):
ifx<60:
return 0;
else:
return 1.0+(x-60)/5*0.5

def exit():
sys.exit()

def score(s):
s =s.decode('gbk')
pos =1
end =0
l=[]
whilepos>0:
t = []
for i in range(0, 9):
pos = s.find("VALIGN="center">", pos)
if pos>0:
end =s.find("r="".join(s[pos+16:end].split())
t.append(r)
pos = end
l.append(t)
for x inl:
out = ""
if x != []:
print "%-4s%sn%-4st%-4s" %(x[0]+'.', x[2], get(x[4]),get(x[5]))
i = i+1
return l

#print 'Begin...'
def getscore():
h =httplib.HTTPConnection('59.67.148.66')
h.connect()

h.request('GET', '/index.asp')
r =h.getresponse()

r.read()
cookie =r.getheader('Set-Cookie')
#print"Cookie: ",cookie
#print 'GetCookie succeed!'

post ={
'Connection':'keep-alive',
'Content-Type':'application/x-www-form-urlencoded',
'Cookie':cookie,
'Referer':'http://59.67.148.66/index.asp',
'Origin':'http://59.67.148.66',
'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5(KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5'
}

h.request('POST', '/index.asp', msg, post)
r =h.getresponse()
if notr.read().find('Object Moved'):
print 'POST failed!'
exit()

#print'Begin get message...'
post ={
'Host':'59.67.148.66',
'Cookie':cookie
}

h.request('GET','/score/xszxcjcy.asp',headers={'Cookie':cookie})
r =h.getresponse()

s =r.read()

l =score(s)
n =len(l)-1
gpa =0.0
fen =0
for x inl:
if len(x) == 0:
break
fen += int(get(x[6]))
gpa += getgpa(int(get(x[5])))*int(get(x[6]))
printgpa/fen
h.close()
return n

getscore()

  

爱华网本文地址 » http://www.aihuau.com/a/25101012/133302.html

更多阅读

玩转小米:2 破解小米收费主题等的最新方法

玩转小米:[2]破解小米收费主题等的最新方法——简介 小米官方主题授权已改变机制,笔者之前发布的破解方法已经失效。但,上有政策,下有对策,不要低估我们米粉的力量!现已有最新的破解方法,亲测可行! 本经验就介绍一下:破解小米商店收费主题等

AFP成绩查询的步骤 afp考试多久出成绩

AFP成绩查询的步骤——简介AFP(金融理财师)---Associate Financial Planner 目前,中国国内实行的是金融理财师(AFP,Associate Financial Planner)和国际金融理财师(CFP)两级认证制度。也就是说,必须要首先获得AFP资格,才能进一步参加CFP

声明:《python获取天津理工大学教务处的最新成绩 天津理工大学成绩查询》为网友北陌深巷分享!如侵犯到您的合法权益请联系我们删除