mirror of https://github.com/testerSunshine/12306
test version
parent
b056211587
commit
c1ce4e4469
|
@ -41,18 +41,36 @@
|
|||
|
||||
set:
|
||||
station_dates:
|
||||
# - "2018-01-27"
|
||||
# - "2018-01-28"
|
||||
- "2018-02-09"
|
||||
- "2018-02-10"
|
||||
# - "2018-02-09"
|
||||
- "2018-02-23"
|
||||
|
||||
station_trains:
|
||||
- "G4741"
|
||||
- "G2365"
|
||||
- "G1371"
|
||||
- "G1337"
|
||||
- "G1377"
|
||||
- "G1329"
|
||||
- "G1031"
|
||||
- "G1013"
|
||||
- "G73"
|
||||
- "G6001"
|
||||
- "G6163"
|
||||
- "G1015"
|
||||
- "G79"
|
||||
- "G6031"
|
||||
- "G279"
|
||||
- "G817"
|
||||
- "G1017"
|
||||
- "G6485"
|
||||
- "G821"
|
||||
- "G1019"
|
||||
- "G6033"
|
||||
- "G75"
|
||||
- "G6025"
|
||||
- "G1021"
|
||||
- "G825"
|
||||
- "G6027"
|
||||
- "G6141"
|
||||
# - "G4741"
|
||||
# - "G2365"
|
||||
# - "G1371"
|
||||
# - "G1337"
|
||||
# - "G1377"
|
||||
# - "G1329"
|
||||
# - "G1302"
|
||||
# - "G1372"
|
||||
# - "G1326"
|
||||
|
@ -65,13 +83,13 @@ set:
|
|||
# - "G1373"
|
||||
# - "G1363"
|
||||
# - "G4933"
|
||||
from_station: "上海"
|
||||
to_station: "邵阳"
|
||||
from_station: "长沙南"
|
||||
to_station: "深圳北"
|
||||
set_type:
|
||||
- "二等座"
|
||||
is_more_ticket: True
|
||||
ticke_peoples:
|
||||
- "文贤平"
|
||||
- "高智"
|
||||
# - "彭淑杰"
|
||||
12306count:
|
||||
# - uesr: ""
|
||||
|
|
|
@ -32,6 +32,29 @@ class GoLogin:
|
|||
# for index, c in enumerate(myurllib2.cookiejar):
|
||||
# stoidinput(c)
|
||||
|
||||
def getRandCode(self):
|
||||
"""
|
||||
识别验证码
|
||||
:return: 坐标
|
||||
"""
|
||||
if self.is_aotu_code:
|
||||
if self.aotu_code_type == 1:
|
||||
return DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], "./tkcode").main()
|
||||
elif self.aotu_code_type == 2:
|
||||
rc = RClient(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"])
|
||||
im = open('./tkcode', 'rb').read()
|
||||
Result = rc.rk_create(im, 6113)
|
||||
if "Result" in Result:
|
||||
return self.codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False)
|
||||
else:
|
||||
if "Error" in Result and Result["Error"]:
|
||||
print Result["Error"]
|
||||
return ""
|
||||
else:
|
||||
img = Image.open('./tkcode')
|
||||
img.show()
|
||||
return self.codexy()
|
||||
|
||||
def readImg(self, code_url):
|
||||
"""
|
||||
增加手动打码,只是登录接口,完全不用担心提交订单效率
|
||||
|
@ -47,26 +70,8 @@ class GoLogin:
|
|||
result = self.httpClint.send(codeimgUrl, is_logger=False)
|
||||
try:
|
||||
open(img_path, 'wb').write(result)
|
||||
if self.is_aotu_code:
|
||||
if self.aotu_code_type == 1:
|
||||
return DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], img_path).main()
|
||||
elif self.aotu_code_type == 2:
|
||||
rc = RClient(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"])
|
||||
im = open('./tkcode', 'rb').read()
|
||||
Result = rc.rk_create(im, 6113)
|
||||
if "Result" in Result:
|
||||
return self.codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False)
|
||||
else:
|
||||
if "Error" in Result and Result["Error"]:
|
||||
print Result["Error"]
|
||||
return ""
|
||||
else:
|
||||
img = Image.open('./tkcode')
|
||||
img.show()
|
||||
return self.codexy()
|
||||
except OSError as e:
|
||||
print (e)
|
||||
return ""
|
||||
|
||||
def codexy(self, Ofset=None, is_raw_input=True):
|
||||
"""
|
||||
|
@ -212,13 +217,13 @@ class GoLogin:
|
|||
while True:
|
||||
self.cookietp()
|
||||
self.httpClint.set_cookies(_jc_save_wfdc_flag="dc", _jc_save_fromStation="%u4E0A%u6D77%u8679%u6865%2CAOH", _jc_save_toStation="%u5170%u5DDE%u897F%2CLAJ", _jc_save_fromDate="2018-02-14", _jc_save_toDate="2018-01-16", RAIL_DEVICEID="EN_3_EGSe2GWGHXJeCkFQ52kHvNCrNlkz9n1GOqqQ1wR0i98WsD8Gj-a3YHZ-XYKeESWgCiJyyucgSwkFOzVHhHqfpidLPcm2vK9n83uzOPuShO3Pl4lCydAtQu4BdFqz-RVmiduNFixrcrN_Ny43135JiEtqLaI")
|
||||
self.randCode = self.readImg(self.urlConf["getCodeImg"]["req_url"])
|
||||
self.readImg(self.urlConf["getCodeImg"]["req_url"])
|
||||
self.randCode = self.getRandCode()
|
||||
login_num += 1
|
||||
self.auth()
|
||||
if self.codeCheck():
|
||||
uamtk = self.baseLogin(user, passwd)
|
||||
if uamtk:
|
||||
self.getUserName(uamtk)
|
||||
break
|
||||
|
||||
def logout(self):
|
||||
|
|
|
@ -19,6 +19,8 @@ from myException.ticketConfigException import ticketConfigException
|
|||
from myException.ticketIsExitsException import ticketIsExitsException
|
||||
from myException.ticketNumOutException import ticketNumOutException
|
||||
from myUrllib.httpUtils import HTTPClient
|
||||
import threading
|
||||
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf-8')
|
||||
|
@ -41,6 +43,8 @@ class select:
|
|||
self.httpClint = HTTPClient()
|
||||
self.confUrl = urlConf.urls
|
||||
self.login = GoLogin(self.httpClint, self.confUrl, self.is_aotu_code, self.aotu_code_type)
|
||||
self.is_download_img = False
|
||||
self.randCode = ""
|
||||
|
||||
def get_ticket_info(self):
|
||||
"""
|
||||
|
@ -136,6 +140,22 @@ class select:
|
|||
tomorrow = today+datetime.timedelta(1)
|
||||
return tomorrow.strftime('%Y-%m-%d')
|
||||
|
||||
def callReadImg(self, code_url):
|
||||
"""
|
||||
下载验证码
|
||||
:param code_url: 验证码url
|
||||
:return:
|
||||
"""
|
||||
self.login.readImg(code_url=code_url)
|
||||
self.is_aotu_code = True
|
||||
|
||||
def callRandCode(self):
|
||||
"""
|
||||
识别验证码
|
||||
:return:
|
||||
"""
|
||||
self.randCode = self.login.getRandCode()
|
||||
|
||||
def getRepeatSubmitToken(self):
|
||||
"""
|
||||
获取提交车票请求token
|
||||
|
@ -228,6 +248,8 @@ class select:
|
|||
break
|
||||
else:
|
||||
print ('正在尝试提交订票...')
|
||||
t = threading.Thread(target=self.callReadImg, args=self.confUrl["codeImgByOrder"]["req_url"])
|
||||
t.start()
|
||||
# self.submitOrderRequestFunc(from_station, to_station, self.time())
|
||||
self.submit_station()
|
||||
self.getPassengerTicketStr(self._station_seat[j].encode("utf8"))
|
||||
|
@ -240,7 +262,7 @@ class select:
|
|||
pass
|
||||
else:
|
||||
pass
|
||||
time.sleep(self.expect_refresh_interval)
|
||||
# time.sleep(self.expect_refresh_interval)
|
||||
else:
|
||||
print "车次配置信息有误,或者返回数据异常,请检查 {}".format(station_ticket)
|
||||
|
||||
|
@ -459,13 +481,16 @@ class select:
|
|||
"_json_at": "",
|
||||
"REPEAT_SUBMIT_TOKEN": self.get_token(),
|
||||
}
|
||||
|
||||
try:
|
||||
for i in range(3):
|
||||
if is_node_code:
|
||||
|
||||
print("正在使用自动识别验证码功能")
|
||||
checkRandCodeAnsyn = self.confUrl["checkRandCodeAnsyn"]["req_url"]
|
||||
codeImgByOrder = self.confUrl["codeImgByOrder"]["req_url"]
|
||||
randCode = self.login.readImg(codeImgByOrder)
|
||||
self.login.readImg(codeImgByOrder)
|
||||
randCode = self.login.getRandCode()
|
||||
randData = {
|
||||
"randCode": randCode,
|
||||
"rand": "randp",
|
||||
|
|
|
@ -9,6 +9,7 @@ import sys
|
|||
|
||||
from config import logger
|
||||
|
||||
|
||||
class HTTPClient(object):
|
||||
|
||||
def __init__(self):
|
||||
|
|
Loading…
Reference in New Issue