四六级查分工具完善版

编程入门 行业动态 更新时间:2024-10-23 15:24:00

<a href=https://www.elefans.com/category/jswz/34/1766520.html style=四六级查分工具完善版"/>

四六级查分工具完善版

在去年12月份的时候曾写过一个CET四六级查分工具,不过由于当时只是编写,并没有进行测试,导致在前几天的CET查分过程中出现了很多bug。然后花了一个多小时将bug都修复了,又花了点时间加了几个功能,同时也优化了原有的枚举方法。

代码当然也做了好几重的修改。很多地方也改变了,所以重新写一次博客。




此次改进:

1)效率极大提升,在网络空闲状态下,查询所需时间小于30秒。

2)功能完善,可以明确自己的考场上限和座位号上限,再也不用等没有必要的时间了。

3)提供了控制台 窗口,能够实时监控程序的运行动态,当然也包括已经查询出来的成绩。

4)10秒钟更新一次查找进度,让你等的不心慌,等的有把握。

下载地址:/    -->>   Download文件夹  -->>   CET四六级查询工具


使用方式等更多问题请详见:  博文最后几行文字


Main.py

__author__ = 'glcsnz123'
#_*_encoding:utf-8_*_
import urllib2, urllib
import sys, time
import thread, threading
from GUI import GUIFrame
from RunMulThread import RunMulThreads, RunMul
import wxcefy = []
wrongurl = []def Check(stid="", name=u""):#print name,type(name)330020121101729#name = unicode(name, "utf-8")post_data = urllib.urlencode({"id": stid.decode("gbk"), "name": name.encode("gbk")});#print post_dataheaders = {"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", \"Accept-Charset": "GBK,utf-8;q=0.7,*;q=0.3", "Accept-Encoding": "gzip,deflate,sdch", \"Accept-Language": "zh-CN,zh;q=0.8", "Cache-Control": "max-age=0", "Connection": "keep-alive", \"Content-Length": "36", "Content-Type": "application/x-www-form-urlencoded", \"Cookie": "cnzz_a30023677=4; sin30023677=; rtime30023677=5; ltime30023677=1356177904700; cnzz_eid30023677=19927958-1318821986-http%3A//www.baidu/s%3Fwd%3D99%25CB%25DE%25C9%25E1%26rsv_bp%3D0%26rsv_spt%3D3%26oq%3D9; searchtime=1356177913","Host": "cet.99sushe", "Origin": "", "Referer": "/", \"User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.20 (KHTML, like Gecko) Chrome/25.0.1337.0 Safari/537.20"};pst = urllib2.Request("", headers=headers);try:pst = urllib2.urlopen(pst, post_data)except Exception, e:try:mylock.acquire()hole.append(stid[-5::1])#print stidfinally:mylock.release()return "w"html = pst.read()return html.decode("gbk")def GetName():#name = raw_input(u"请输入你的姓名:");return GUIFrame.cetnamedef GetLevel():#return raw_input("CET?");return GUIFrame.cetlevanslist = [];
hole = []
mylock = thread.allocate_lock()def LoopOne(stid, name):while True:try:mylock.acquire()if len(hole) <= 0:breaki = hole[0]del hole[0]finally:mylock.release()result = Check(stid + i, name)if len(result) >= 10:print resultanslist.append(result.split(','))cefy.append(stid + i)def GetLocalNum():#return "330020"#return raw_input("请输入准考证号的前六位:")return GUIFrame.localid.split(",")def GetYear(date):year = int(str(date[0])[2:])if date[1] < 8:year -= 1return str(year)def Init():app = wx.PySimpleApp();frame = GUIFrame()frame.Show(True)app.MainLoop();runmt = Nonedef RunMul():apps = wx.PySimpleApp();global runmtrunmt = RunMulThreads()runmt.Show(True)runmt.start()apps.MainLoop();if __name__ == "__main__":print "The console is a way to show if the program is running well.\nDon't kill this!!!"Init()name = GetName();try:names = name[0:6]except Exception, e:exit()date = time.localtime(time.time())stidls = GetLocalNum()RunMulThreads.cetProc = 0thread.start_new_thread(RunMul, ())time.sleep(1)ape = -1for stid in stidls:ape += 1if len(stid) != 6:RunMulThreads.ShowLabel = u"  正在努力创建60个线程...\n\n创建完成!^0^~ 开始查找..."RunMulThreads.cetProc = 100RunMulThreads.anslist.append(u"输入有误,程序终止~\n错误准考证号:" + str(stid))breakstid += GetYear(date)if int(date[1]) >= 8 or int(date[1]) < 2:stid += '1'else:stid += '2'cetlv = GetLevel()if cetlv == '4':stid += '1'else:stid += '2'print stid#RunMulThreads.ShowLabel = ""time.sleep(1);print "KaoChangHao: ", GUIFrame.kchlimit, "| ZuoWeiHao: ", GUIFrame.zwhlimitglobal holefor i in range(1, GUIFrame.kchlimit):for j in range(1, GUIFrame.zwhlimit):hole.append("%03d%02d" % (i, j))now = len(hole) * 1.0;for i in range(0, 60):thread.start_new_thread(LoopOne, (stid, names))time.sleep(0.1);#passRunMulThreads.ShowLabel = u"     正在努力创建60个线程...\n\n创建完成!^0^~ 开始查找..."while True:print "当前完成度:%.2f%%" % (100.0 - (len(hole) * 100.0 / (now)))RunMulThreads.cetProc = (100.0 - (len(hole) * 100.0 / (now))) / (len(stidls)) + ape * (100.0 / len(stidls))if len(hole) == 0:if RunMulThreads.cetProc > 90:RunMulThreads.cetProc = 100breaktime.sleep(15);#result=Check()#print result#anslist.append(result.split(','))RunMulThreads.anslist = []for i in range(len(anslist)):tmp = anslist[i]scors = u"姓名: " + tmp[-1]scors += u"\n准考证号: " + cefy[i]scors += u"\n学校: " + tmp[-2]scors += u"\n总分: " + tmp[-3]scors += u"\n听力: " + tmp[1]scors += u"\n阅读: " + tmp[2]scors += u"\n综合: " + tmp[3]scors += u"\n写作: " + tmp[4]RunMulThreads.anslist.append(scors)print scorstry:f = open("history_utf-8_open.txt", "a")f.write(scors.encode("utf-8"))f.write("\n--------------------------\n")finally:f.close()#runmt.join()time.sleep(10)while RunMulThreads.Flag == False:time.sleep(2);

GUI.py

__author__ = 'glcsnz123'
#_*_encoding:utf-8_*_
import wx
import sysglobal sch, iddict, schdict
sch = [u'浙江师范大学', u'浙江工商大学', u'浙江大学', u'宁波大学', u'绍兴文理学院', u'湖州师范学院', u'浙江工业大学', u'其他']
iddict = ["330020", "330382,330381", '330011,330012,330013,330015', '330030', '330090,330091,330092', '330100', \'330361,330362', '330020'];
schdict = {}
for i in range(len(sch)):schdict.setdefault(sch[i], iddict[i])class GUIFrame(wx.Frame):def __init__(self):wx.Frame.__init__(self, parent=None, id=-1, title="CET4|6 ShowScore", size=(380, 300))self.panel = wx.Panel(self, id=-1);self.panel.SetBackgroundColour("white")self.__class__.kchlimit = 200self.__class__.zwhlimit = 30#create the radioboxself.cetrb = wx.RadioBox(self.panel, id=-1, label="CET Level", name="radiobox", choices=['CET4', 'CET6'],pos=(120, 30))#create the school listself.cetcs = wx.Choice(self.panel, id=-1, choices=sch, name="choice", pos=(50, 120))self.cetcs.SetStringSelection(sch[0])#create the textctrlself.cettc = wx.TextCtrl(self.panel, -1, u"准考证前六位,多个输入请用','隔开", pos=(170, 120), size=(150, 30))self.cettc.Show(False);self.cetname = wx.TextCtrl(self.panel, -1, u"请输入您的姓名", pos=(100, 170), size=(150, 30))#create the static textself.cetsc = wx.StaticText(self.panel, -1, u"you can't see this!", pos=(180, 123), size=(150, 30))self.cetsc.SetLabel(schdict[self.cetcs.GetStringSelection()])#create the submit buttonself.cetbut = wx.Button(self.panel, -1, label=u"确定", pos=(135, 210))self.cetkch = wx.Button(self.panel, -1, label=u"默认考场上限200,座位号上限30,如需更改,请点击此处", size=(380, 28))#create the bindself.Bind(wx.EVT_CHOICE, self.OnOtherChoice, self.cetcs)self.Bind(wx.EVT_BUTTON, self.OnSubmit, self.cetbut)self.Bind(wx.EVT_CLOSE, self.OnClose)self.Bind(wx.EVT_BUTTON, self.SetKZLimit, self.cetkch)def SetKZLimit(self, event):ted = wx.TextEntryDialog(self, u"输入两个整数分别表示考场号和座位号上限(用英文状态下输入的“逗号”隔开)", style=wx.OK | wx.CANCEL)if ted.ShowModal() == wx.ID_OK:try:self.__class__.kchlimit, self.__class__.zwhlimit = map(int, ted.GetValue().split(","))except Exception, e:self.__class__.kchlimit, self.__class__.zwhlimit = 200, 30def OnClose(self, event):sys.exit()def OnSubmit(self, event):self.__class__.cetname = self.cetname.GetValue()if self.cetrb.GetSelection() == 0:self.__class__.cetlev = '4'else:self.__class__.cetlev = '6'if self.cetcs.GetStringSelection() == u"其他":self.__class__.localid = self.cettc.GetValue()else:self.__class__.localid = self.cetsc.GetLabel()self.Destroy()def OnOtherChoice(self, event):if self.cetcs.GetStringSelection() == u"其他":self.cetsc.Show(False)self.cettc.Show(True)self.Refresh()elif self.cetcs.GetStringSelection() != "":self.cettc.Show(False)self.cetsc.Show(True)self.cetsc.SetLabel(schdict[self.cetcs.GetStringSelection()])self.Refresh()if __name__ == '__main__':#main functionapp = wx.PySimpleApp();frame = GUIFrame()frame.Show(True)app.MainLoop();

RunMulThread.py

__author__ = 'glcsnz123'
#_*_encoding:utf-8_*_
import wx
import thread, threading;
import sys, timer, timeglobal runmtclass RunMulThreads(wx.Frame, threading.Thread):def __init__(self):wx.Frame.__init__(self, parent=None, id=-1, title="CET4|6 ShowScore", size=(400, 400))threading.Thread.__init__(self)self.panel = wx.Panel(self, id=-1);self.panel.SetBackgroundColour("white")self.curnow = 0self.__class__.Flag = False#create the Gaugeself.cetGua = wx.Gauge(self.panel, -1, 100, name="gauge", pos=(50, 90), size=(300, 20))self.__class__.cetProc = 0self.cetGua.Show(False)#create the staicTextself.__class__.ShowLabel = u"  正在努力创建60个线程..."self.cetShowSt = wx.StaticText(self.panel, -1, self.__class__.ShowLabel, pos=(120, 25))#create the staticTextself.cetRes = wx.StaticText(self.panel, -1, u"you can't see me!", pos=(140, 130))self.cetRes.Show(False)self.__class__.anslist = [];#create the buttonself.cetprebut = wx.Button(self.panel, -1, label=u"上一个", pos=(100, 300))self.cetnextbut = wx.Button(self.panel, -1, label=u"下一个", pos=(200, 300))self.cetprebut.Show(False)self.cetnextbut.Show(False)#create the bindself.Bind(wx.EVT_BUTTON, self.PreResult, self.cetprebut)self.Bind(wx.EVT_BUTTON, self.NextResult, self.cetnextbut)self.Bind(wx.EVT_CLOSE, self.ErrorLog)#open the fileself.fe = open("error.log", "a")def ErrorLog(self, event):self.__class__.Flag = Truetry:print >> self.fe, self.__class__.anslist;except  Exception, e:print "write error"finally:self.fe.close()self.Destroy()def PreResult(self, event):self.curnow -= 1self.curnow %= len(self.__class__.anslist)self.cetRes.SetLabel(self.__class__.anslist[self.curnow])def NextResult(self, event):self.curnow += 1self.curnow %= len(self.__class__.anslist)self.cetRes.SetLabel(self.__class__.anslist[self.curnow])def run(self):while True:self.cetShowSt.SetLabel(self.__class__.ShowLabel)time.sleep(1);if len(self.cetShowSt.GetLabel()) > 30:break;time.sleep(1)self.cetGua.Show(True)while True:self.cetGua.SetValue(self.__class__.cetProc)time.sleep(6)if self.__class__.cetProc >= 100:self.cetGua.SetValue(self.__class__.cetProc)break;self.cetRes.SetLabel(u"努力处理数据中...")self.cetRes.Show(True)time.sleep(1)self.curnow = 0if len(self.__class__.anslist) > 0:self.cetRes.SetLabel(self.__class__.anslist[self.curnow])self.cetprebut.Show(True)self.cetnextbut.Show(True)else:self.cetRes.SetLabel(u"查找失败~~~~~~")def RunMul():app = wx.PySimpleApp();runmt = RunMulThreads()runmt.Show(True)app.MainLoop();if __name__ == '__main__':#main functionthread.start_new_thread(RunMul, ())#print "yes"#thread.start_new_thread(RunMul, ())#time.sleep(2000)













更多推荐

四六级查分工具完善版

本文发布于:2024-02-26 13:25:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1702639.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:四六级   查分   工具

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!