-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
193 lines (163 loc) · 5.78 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
__author__ = 'glcsnz123'
#_*_encoding:utf-8_*_
import urllib2, urllib
import sys, time
import thread, threading
from GUI import GUIFrame
from RunMulThread import RunMulThreads, RunMul
import wx
cefy = []
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_data
headers = {"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.com/s%3Fwd%3D99%25CB%25DE%25C9%25E1%26rsv_bp%3D0%26rsv_spt%3D3%26oq%3D9; searchtime=1356177913"
,
"Host": "cet.99sushe.com", "Origin": "http://cet.99sushe.com", "Referer": "http://cet.99sushe.com/", \
"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("http://cet.99sushe.com/s", headers=headers);
try:
pst = urllib2.urlopen(pst, post_data)
except Exception, e:
try:
mylock.acquire()
hole.append(stid[-5::1])
#print stid
finally:
mylock.release()
return "w"
html = pst.read()
return html.decode("gbk")
def GetName():
#name = raw_input(u"请输入你的姓名:");
return GUIFrame.cetname
def GetLevel():
#return raw_input("CET?");
return GUIFrame.cetlev
anslist = [];
hole = []
mylock = thread.allocate_lock()
def LoopOne(stid, name):
while True:
try:
mylock.acquire()
if len(hole) <= 0:
break
i = hole[0]
del hole[0]
finally:
mylock.release()
result = Check(stid + i, name)
if len(result) >= 10:
print result
anslist.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 -= 1
return str(year)
def Init():
app = wx.PySimpleApp();
frame = GUIFrame()
frame.Show(True)
app.MainLoop();
runmt = None
def RunMul():
apps = wx.PySimpleApp();
global runmt
runmt = 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 = 0
thread.start_new_thread(RunMul, ())
time.sleep(1)
ape = -1
for stid in stidls:
ape += 1
if len(stid) != 6:
RunMulThreads.ShowLabel = u" 正在努力创建60个线程...\n\n创建完成!^0^~ 开始查找..."
RunMulThreads.cetProc = 100
RunMulThreads.anslist.append(u"输入有误,程序终止~\n错误准考证号:" + str(stid))
break
stid += 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.zwhlimit
global hole
for 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);
#pass
RunMulThreads.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 = 100
break
time.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 scors
try:
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);