37,720
社区成员
发帖
与我相关
我的任务
分享
<form name="form" method="post" action="login.asp">
<tr>
<td width="100" height="30" align="right" valign="middle">姓 名:</td>
<td width="100" height="30" align="left" valign="middle"><input name="user" type="text" id="user" size="15" maxlength="20" /></td>
</tr>
<tr>
<td width="100" height="30" align="right" valign="middle">学 号:</td>
<td width="100" height="30" align="left" valign="middle"><input name="Password" type="text" id="Password" size="15" maxlength="15" /></td>
</tr>
#!/usr/bin/python encoding=utf-8
import urllib,urllib2,cookielib,json,time,hashlib,re
class CQedu(object):
def __init__(self, user, password, origURL, domain):
self.user=user
self.password=password
self.origURL=origURL
self.domain=domain
self.cj = cookielib.LWPCookieJar()
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
urllib2.install_opener(self.opener)
def login(self):
print 'Logining...'
params = {'user':self.user,'Password':self.password,'origURL':self.origURL,'domain':self.domain}
req = urllib2.Request(r'http://www2.cqjtu.edu.cn/sjxz/login.asp', urllib.urlencode(params))
respond = self.opener.open(req)
print respond.geturl()
html = respond.read()
print html
if __name__ == "__main__":
cqedu = CQedu('中文姓名'.decode('utf-8').encode('GB2312'),'数字学号'.decode('utf-8').encode('GB2312'),
'http://www2.cqjtu.edu.cn/sjxz/index.asp','202.202.240.7')
cqedu.login()