def getgpa(): import jw if len( jw.result ): jw.result = [] stuid = request.form.get( 'user', '' ) pwd = request.form.get( 'pass', '' ) fs = request.form.get( 'Destroy', '' ) noggl = request.form.get( 'guaguale', '' ) isnative = request.form.get( 'native', '' ) #print 'fs', fs print 'id', stuid if fs: try: ineed=jw.jw(stuid, pwd) except: ineed = [ u"鉴于本人水平问题,解析你的课程发生了意外而我无能为力" ] finally: return render_template( 'jw.html', ineed=ineed ) jk = jw2(stuid, pwd) if jk is 'tiancangcang': return 'error password. How are you?' if isnative: print 'i am in' return nativejw.jw(stuid, pwd) if noggl: return render_template( 'newshowscore.html', infos=jk ) else: return render_template( 'guashowscore.html', infos=jk )
> Date : 15/09/05 - 19:02 ''' from jw import jw from hashlib import md5 import sys import requests from optparse import OptionParser parser = OptionParser( usage='python this.py --stuid 123 --pwd 321' ) parser.add_option("-s", "--stuid", dest="stuid",help="Student id") parser.add_option("-p", "--pwd", dest="pwd",help="Password") (options, args) = parser.parse_args() stuid = options.stuid pwd = options.pwd if not (stuid and pwd): parser.parse_args(['-h']) session = requests.Session() loginurl = 'http://58.192.142.134:7777/pls/wwwbks/bks_login2.uniteLogin?stuid={}&pwd={}'.format( stuid, md5(pwd).hexdigest().upper() ) #print loginurl s = session.get( loginurl ) if len( s.content ) < 100: print 'Login Failed!\nerror id or password or network' sys.exit(1) s1 = session.get( 'http://58.192.142.134:7777/pls/wwwbks/bkscjcx.curscopre' ).content.decode('gbk').encode('utf-8') s2 = session.get( 'http://58.192.142.134:7777/pls/wwwbks/bkscjcx.yxkc' ).content.decode('gbk').encode('utf-8') jw( s1, s2 ) session.close()