Skip to content

Instantly share code, notes, and snippets.

@heruoxin
Last active January 3, 2016 05:19
Show Gist options
  • Save heruoxin/8414790 to your computer and use it in GitHub Desktop.
Save heruoxin/8414790 to your computer and use it in GitHub Desktop.
成都理工自动评教脚本……
#!/usr/bin/python
# -*-encoding:utf-8 -*-
#CDUT teacher rating script
from urllib import urlencode
import urllib2, cookielib, re
data = {
'uname' : 'YOUR STUDENT NUMBER',
'upwd' : 'YOUR PASSWORD'
}
#login
encoded_data = urlencode(data)
cookie = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
urllib2.install_opener(opener)
urllib2.urlopen('http://202.115.133.161/login.php', encoded_data)
#get your classes list
pj_xspj_php=urllib2.urlopen('http://202.115.133.161/pj_xspj/pj_xspj.php').read().decode('gb2312')
class_number_list = re.findall("<td></td>|<td>[\S\s]+?</td>", pj_xspj_php)
class_number_list=class_number_list[5::8]
print class_number_list
#rate all teachers
score = {
'jxbh':'233233',
'sflg':'1',
'pf_1':'100',
'pf_2':'100',
'pf_3':'100',
'pf_4':'100',
'pf_5':'100',
'tx_1':'',
'tx_2':'',
'tx_3':'',
'BtSubmit':'+%CC%E1+%BD%BB+',
}
def post_score(class_number):
score['jxbh'] = class_number
result0=urllib2.urlopen('http://202.115.133.161/pj_xspj/pj_xspj_df_new.php', urlencode(score))
print result0.read().decode('gb2312')
for i in class_number_list:
ii = i[4:-5]
print ii
post_score(ii)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment