parent
d8a91c1fc9
commit
2ed2916397
|
@ -176,25 +176,13 @@ class select:
|
||||||
print("未查找到常用联系人")
|
print("未查找到常用联系人")
|
||||||
raise PassengerUserException("未查找到常用联系人,请先添加联系人在试试")
|
raise PassengerUserException("未查找到常用联系人,请先添加联系人在试试")
|
||||||
|
|
||||||
def leftTicketLog(self, from_station, to_station):
|
def submitOrderRequestFunc(self, from_station, to_station, station_date=None):
|
||||||
"""
|
select_url = 'https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT'.format(
|
||||||
模拟进入车次列表页
|
self.station_date if station_date is None else station_date, from_station, to_station)
|
||||||
:param from_station:
|
station_ticket = json.loads(myurllib2.get(select_url), encoding='utf-8')
|
||||||
:param to_station:
|
return station_ticket
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
leftTicketLogUrl = 'https://kyfw.12306.cn/otn/leftTicket/log?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT'.format(
|
|
||||||
self.station_date, from_station, to_station)
|
|
||||||
leftTicketLog = json.loads(myurllib2.get(leftTicketLogUrl), encoding='utf-8')
|
|
||||||
if "status" in leftTicketLog and leftTicketLog["status"] is True:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
if "message" in leftTicketLog and leftTicketLog["message"]:
|
|
||||||
print leftTicketLog["message"]
|
|
||||||
elif "validateMessages" in leftTicketLog and leftTicketLog["validateMessages"]:
|
|
||||||
print leftTicketLog["validateMessages"]
|
|
||||||
|
|
||||||
def submitOrderRequest(self, from_station, to_station):
|
def submitOrderRequestImplement(self, from_station, to_station,):
|
||||||
"""
|
"""
|
||||||
提交车次信息
|
提交车次信息
|
||||||
车次对应字典
|
车次对应字典
|
||||||
|
@ -209,8 +197,7 @@ class select:
|
||||||
} 参照station_seat()方法
|
} 参照station_seat()方法
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
select_url = 'https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT'.format(self.station_date, from_station, to_station)
|
station_ticket = self.submitOrderRequestFunc(from_station, to_station)
|
||||||
station_ticket = json.loads(myurllib2.get(select_url), encoding='utf-8')
|
|
||||||
value = station_ticket['data']
|
value = station_ticket['data']
|
||||||
if not value:
|
if not value:
|
||||||
print ('{0}-{1} 车次坐席查询为空...'.format(self.from_station, self.to_station))
|
print ('{0}-{1} 车次坐席查询为空...'.format(self.from_station, self.to_station))
|
||||||
|
@ -233,6 +220,7 @@ class select:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print ('正在尝试提交订票...')
|
print ('正在尝试提交订票...')
|
||||||
|
self.submitOrderRequestFunc(from_station, to_station, self.time())
|
||||||
if self.check_user():
|
if self.check_user():
|
||||||
self.submit_station()
|
self.submit_station()
|
||||||
self.getPassengerTicketStr(self._station_seat[j].encode("utf8"))
|
self.getPassengerTicketStr(self._station_seat[j].encode("utf8"))
|
||||||
|
@ -393,13 +381,11 @@ class select:
|
||||||
:param token:
|
:param token:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
old_train_date = self.get_ticketInfoForPassengerForm()['queryLeftTicketRequestDTO']['train_date']+"00:00:00" # 模仿12306格式 Sun May 21 2017 00:00:00 GMT+0800 (中国标准时间)
|
l_time = time.localtime(time.time())
|
||||||
m_time = time.mktime(time.strptime(old_train_date, "%Y%m%d%H:%M:%S"))
|
new_train_date = time.strftime("%a %b %d %Y", l_time)
|
||||||
l_time = time.localtime(m_time)
|
|
||||||
new_train_date = time.strftime("%a %b %d %Y %H:%M:%S", l_time)
|
|
||||||
getQueueCountUrl = 'https://kyfw.12306.cn/otn/confirmPassenger/getQueueCount'
|
getQueueCountUrl = 'https://kyfw.12306.cn/otn/confirmPassenger/getQueueCount'
|
||||||
data = {
|
data = {
|
||||||
'train_date': new_train_date,
|
'train_date': new_train_date + "00:00:00 GMT+0800 (CST)",
|
||||||
'train_no': self.get_ticketInfoForPassengerForm()['queryLeftTicketRequestDTO']['train_no'],
|
'train_no': self.get_ticketInfoForPassengerForm()['queryLeftTicketRequestDTO']['train_no'],
|
||||||
'stationTrainCode': self.get_ticketInfoForPassengerForm()['queryLeftTicketRequestDTO']['station_train_code'],
|
'stationTrainCode': self.get_ticketInfoForPassengerForm()['queryLeftTicketRequestDTO']['station_train_code'],
|
||||||
'seatType': self.set_type,
|
'seatType': self.set_type,
|
||||||
|
@ -609,7 +595,7 @@ class select:
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
from_station, to_station = self.station_table(self.from_station, self.to_station)
|
from_station, to_station = self.station_table(self.from_station, self.to_station)
|
||||||
if self.leftTicketLog(from_station, to_station):
|
# if self.leftTicketLog(from_station, to_station):
|
||||||
num = 1
|
num = 1
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue