python登录URP系统自动评教

登录urp系统,自动进行教师评教,默认好评,想要更改,代码中已经标好

代码

#-*-coding:utf-8-*-
#python3.4 projiet
import http.cookiejar, urllib.request,re,time
header = {
    'Connection': 'Keep-Alive',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language': 'en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
    'Accept-Encoding': 'gzip, deflate',
  #  'Host': '',
    }

#//////////////////////////////////////////////////////////
#如果要使用的话修改这里的三个参数
index_url = ''                    #登录网址
teacher_list_url = ''             #评教名单网址
paper_url = ''            #评教页面网址
submit_url = ''                   #评教提交表单网址
#//////////////////////////////////////////////////////////
def get_paper_form_postdata(wjbm,bpr,pgnr,L = []):
    
    if len(L)==0:
        postDict = {
        'wjbm':wjbm,
        'bpr':bpr,
        'pgnr':pgnr,
        'oper':'wjShow',
        #'wjmc':'2014-2015-2%CC%E5%D3%FD%BF%CE',     
        #'bprm':'%CE%E2%B1%F6',                                                                   
        #'pgnrm':'%CC%E5%D3%FD%A3%A8%B6%FE%A3%A9',                 
        'pageSize':'20',
        'page':'1',
        'currentPage':'1',
        'pageNo':''
        }
    else:
        postDict = {
            'wjbm':wjbm,
            'bpr':bpr,
            'pgnr':pgnr,
          #  'zgpj':
            }
        for x in L:
            postDict[x] = '10_1'     #默认全都是最好想修改去urp看每个评级的值

    postData = urllib.parse.urlencode(postDict).encode()
    return postData



print('默认都是好评,如果不想给那个老师都好,请登陆网站先对那个老师进行评教!')
id = input('Input your number:')
password = input('please enter your password: ')
postDict = {
        
        b'zjh': id,
        b'mm': password,
}
postData = urllib.parse.urlencode(postDict).encode()                                                         
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
r = opener.open(index_url,postData)                                                                                 #1.login
#get cookie
r = opener.open(teacher_list_url)                                                                                       #2.get the page list
html = r.read().decode('GBK') #get teacher list   
html_select = re.findall('

你可能感兴趣的:(python登录URP系统自动评教)