mirror of https://github.com/testerSunshine/12306
create select num people
parent
150a2440fe
commit
c59d1cf8d3
|
@ -35,11 +35,11 @@
|
|||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="select_ticket_info.py" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/init/select_ticket_info.py">
|
||||
<file leaf-file-name="haha.py" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/haha.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2679">
|
||||
<caret line="141" column="22" lean-forward="false" selection-start-line="141" selection-start-column="22" selection-end-line="141" selection-end-column="22" />
|
||||
<state relative-caret-position="114">
|
||||
<caret line="6" column="0" lean-forward="false" selection-start-line="6" selection-start-column="0" selection-end-line="17" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -47,14 +47,12 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="haha.py" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/haha.py">
|
||||
<file leaf-file-name="select_ticket_info.py" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/init/select_ticket_info.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="304">
|
||||
<caret line="16" column="21" lean-forward="false" selection-start-line="16" selection-start-column="21" selection-end-line="16" selection-end-column="21" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
</folding>
|
||||
<state relative-caret-position="1176">
|
||||
<caret line="257" column="80" lean-forward="true" selection-start-line="257" selection-start-column="80" selection-end-line="257" selection-end-column="80" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -69,11 +67,11 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="run.py" pinned="false" current-in-tab="true">
|
||||
<file leaf-file-name="run.py" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/run.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="152">
|
||||
<caret line="8" column="5" lean-forward="true" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
|
||||
<caret line="8" column="5" lean-forward="false" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -119,8 +117,8 @@
|
|||
<option value="$PROJECT_DIR$/init/login.py" />
|
||||
<option value="$PROJECT_DIR$/damatuCode/damatuWeb.py" />
|
||||
<option value="$PROJECT_DIR$/myUrllib/myurllib2.py" />
|
||||
<option value="$PROJECT_DIR$/haha.py" />
|
||||
<option value="$PROJECT_DIR$/init/select_ticket_info.py" />
|
||||
<option value="$PROJECT_DIR$/haha.py" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -152,6 +150,7 @@
|
|||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scratches" />
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
|
@ -164,20 +163,6 @@
|
|||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="12306login" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="12306login" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="myUrllib" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="12306login" />
|
||||
|
@ -194,7 +179,6 @@
|
|||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
|
@ -213,17 +197,18 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$" />
|
||||
<recent name="$PROJECT_DIR$/init" />
|
||||
<recent name="$PROJECT_DIR$/myException" />
|
||||
<recent name="$PROJECT_DIR$/damatuCode" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$" />
|
||||
<recent name="$PROJECT_DIR$/init" />
|
||||
<recent name="$PROJECT_DIR$/headers" />
|
||||
</key>
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="D:\pyWork\12306login\init" />
|
||||
<recent name="$PROJECT_DIR$" />
|
||||
<recent name="$PROJECT_DIR$/init" />
|
||||
<recent name="$PROJECT_DIR$/myException" />
|
||||
<recent name="$PROJECT_DIR$/damatuCode" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
|
@ -576,6 +561,7 @@
|
|||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="2576" height="1416" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
|
||||
|
@ -583,9 +569,9 @@
|
|||
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.27698308" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297587" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.15234375" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.15234375" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297587" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32924962" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.20903522" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
|
@ -637,7 +623,7 @@
|
|||
<state relative-caret-position="702">
|
||||
<caret line="41" column="28" lean-forward="false" selection-start-line="41" selection-start-column="28" selection-end-line="41" selection-end-column="60" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
<element signature="e#23#34#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -663,10 +649,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="378">
|
||||
<caret line="25" column="49" lean-forward="false" selection-start-line="25" selection-start-column="40" selection-end-line="25" selection-end-column="49" />
|
||||
<folding>
|
||||
<element signature="e#41#54#0" expanded="true" />
|
||||
<element signature="e#1235#1250#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -682,7 +664,7 @@
|
|||
<state relative-caret-position="702">
|
||||
<caret line="41" column="28" lean-forward="false" selection-start-line="41" selection-start-column="28" selection-end-line="41" selection-end-column="60" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
<element signature="e#23#34#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -708,10 +690,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="378">
|
||||
<caret line="25" column="49" lean-forward="false" selection-start-line="25" selection-start-column="40" selection-end-line="25" selection-end-column="49" />
|
||||
<folding>
|
||||
<element signature="e#41#54#0" expanded="true" />
|
||||
<element signature="e#1235#1250#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -727,7 +705,7 @@
|
|||
<state relative-caret-position="702">
|
||||
<caret line="41" column="28" lean-forward="false" selection-start-line="41" selection-start-column="28" selection-end-line="41" selection-end-column="60" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
<element signature="e#23#34#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -753,10 +731,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="162">
|
||||
<caret line="11" column="130" lean-forward="true" selection-start-line="11" selection-start-column="34" selection-end-line="11" selection-end-column="130" />
|
||||
<folding>
|
||||
<element signature="e#41#54#0" expanded="true" />
|
||||
<element signature="e#1235#1250#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -764,10 +738,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#41#54#0" expanded="true" />
|
||||
<element signature="e#1235#1250#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -777,10 +747,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="144">
|
||||
<caret line="10" column="24" lean-forward="false" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="24" />
|
||||
<folding>
|
||||
<element signature="e#41#54#0" expanded="true" />
|
||||
<element signature="e#1235#1250#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -816,10 +782,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="252">
|
||||
<caret line="14" column="0" lean-forward="true" selection-start-line="14" selection-start-column="0" selection-end-line="14" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#41#54#0" expanded="true" />
|
||||
<element signature="e#1235#1250#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -850,7 +812,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="194">
|
||||
<caret line="253" column="53" lean-forward="true" selection-start-line="253" selection-start-column="11" selection-end-line="253" selection-end-column="53" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -866,30 +827,6 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-120">
|
||||
<caret line="36" column="0" lean-forward="false" selection-start-line="36" selection-start-column="0" selection-end-line="36" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#41#54#0" expanded="true" />
|
||||
<element signature="e#1235#1250#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/init/select_ticket_info.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2679">
|
||||
<caret line="141" column="22" lean-forward="false" selection-start-line="141" selection-start-column="22" selection-end-line="141" selection-end-column="22" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/haha.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="304">
|
||||
<caret line="16" column="21" lean-forward="false" selection-start-line="16" selection-start-column="21" selection-end-line="16" selection-end-column="21" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -904,7 +841,25 @@
|
|||
<entry file="file://$PROJECT_DIR$/run.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="152">
|
||||
<caret line="8" column="5" lean-forward="true" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
|
||||
<caret line="8" column="5" lean-forward="false" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/haha.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="114">
|
||||
<caret line="6" column="0" lean-forward="false" selection-start-line="6" selection-start-column="0" selection-end-line="17" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#23#34#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/init/select_ticket_info.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1176">
|
||||
<caret line="257" column="80" lean-forward="true" selection-start-line="257" selection-start-column="80" selection-end-line="257" selection-end-column="80" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
|
@ -14,4 +14,19 @@ submitParams = [
|
|||
('query_to_station_name', 1) # 到站名称,汉字
|
||||
]
|
||||
|
||||
print urllib.unquote()
|
||||
print urllib.unquote()
|
||||
|
||||
|
||||
|
||||
|
||||
class a:
|
||||
def __init__(self, factory):
|
||||
pass
|
||||
def b(self):
|
||||
pass
|
||||
|
||||
class c:
|
||||
def __init__(self):
|
||||
pass
|
||||
def d(self):
|
||||
return a().b()
|
|
@ -12,8 +12,27 @@ from myUrllib import myurllib2
|
|||
|
||||
class select:
|
||||
def __init__(self, from_station, to_station):
|
||||
self.from_station = from_station
|
||||
self.to_station = to_station
|
||||
self.from_station, self.to_station = self.station_table(from_station, to_station)
|
||||
self.order_request_params = {} # 订单提交时的参数
|
||||
self.ticketInfoForPassengerForm = {} # 初始化当前页面参数
|
||||
self.current_seats = {} # 席别信息
|
||||
self.token = ''
|
||||
self.set_type = ''
|
||||
|
||||
def get_order_request_params(self):
|
||||
return self.order_request_params
|
||||
|
||||
def get_ticketInfoForPassengerForm(self):
|
||||
return self.ticketInfoForPassengerForm
|
||||
|
||||
def get_current_seats(self):
|
||||
return self.current_seats
|
||||
|
||||
def get_token(self):
|
||||
return self.token
|
||||
|
||||
def get_set_type(self):
|
||||
return self.set_type
|
||||
|
||||
def station_seat(self, index):
|
||||
"""
|
||||
|
@ -32,7 +51,7 @@ class select:
|
|||
}
|
||||
return seat[index]
|
||||
|
||||
def station_table(self):
|
||||
def station_table(self, from_station, to_station):
|
||||
"""
|
||||
读取车站信息
|
||||
:param station:
|
||||
|
@ -46,8 +65,8 @@ class select:
|
|||
# print info[i]
|
||||
n_info = info[i].split('|')
|
||||
station_name[n_info[1]] = n_info[2]
|
||||
from_station = station_name[self.from_station]
|
||||
to_station = station_name[self.to_station]
|
||||
from_station = station_name[from_station]
|
||||
to_station = station_name[to_station]
|
||||
return from_station, to_station
|
||||
|
||||
def time(self):
|
||||
|
@ -62,11 +81,23 @@ class select:
|
|||
"""
|
||||
initdc_url = 'https://kyfw.12306.cn/otn/confirmPassenger/initDc'
|
||||
initdc_result = myurllib2.get(initdc_url)
|
||||
name = r"var globalRepeatSubmitToken = '(\S+)'"
|
||||
token = re.search(name, initdc_result).group(1)
|
||||
return token
|
||||
token_name = re.compile(r"var globalRepeatSubmitToken = '(\S+)'")
|
||||
ticketInfoForPassengerForm_name = re.compile(r'var ticketInfoForPassengerForm=(\{.+\})?')
|
||||
order_request_params_name = re.compile(r'var orderRequestDTO=(\{.+\})?')
|
||||
# if token_name and ticketInfoForPassengerForm_name and order_request_params_name:
|
||||
self.token = re.search(token_name, initdc_result).group(1)
|
||||
re_tfpf = re.findall(ticketInfoForPassengerForm_name, initdc_result)
|
||||
re_orp = re.findall(order_request_params_name, initdc_result)
|
||||
if re_tfpf:
|
||||
self.ticketInfoForPassengerForm = json.loads(re_tfpf[0].replace("'", '"'))
|
||||
else:
|
||||
print('车次获取信息为空')
|
||||
if re_orp:
|
||||
self.order_request_params = json.loads(re_orp[0].replace("'", '"'))
|
||||
else:
|
||||
print('订单获取信息为空')
|
||||
|
||||
def getPassengerDTOs(self, token):
|
||||
def getPassengerDTOs(self):
|
||||
"""
|
||||
获取乘客信息
|
||||
:return:
|
||||
|
@ -74,7 +105,7 @@ class select:
|
|||
get_passengerDTOs = 'https://kyfw.12306.cn/otn/confirmPassenger/getPassengerDTOs'
|
||||
get_data = {
|
||||
'_json_att': None,
|
||||
'REPEAT_SUBMIT_TOKEN': token
|
||||
'REPEAT_SUBMIT_TOKEN': self.token
|
||||
}
|
||||
jsonData = json.loads(myurllib2.Post(get_passengerDTOs, get_data))
|
||||
if 'data' in jsonData and jsonData['data'] and 'normal_passengers' in jsonData['data'] and jsonData['data'][
|
||||
|
@ -89,29 +120,33 @@ class select:
|
|||
print("未查找到常用联系人")
|
||||
|
||||
def submitOrderRequest(self):
|
||||
from_station, to_station = self.station_table()
|
||||
"""
|
||||
提交车次信息
|
||||
:return: 车次信息,座位号
|
||||
"""
|
||||
|
||||
select_url = 'https://kyfw.12306.cn/otn/leftTicket/query?' \
|
||||
'leftTicketDTO.train_date={}&leftTicketDTO.from_station={}' \
|
||||
'&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(self.time(), from_station, to_station)
|
||||
'&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(self.time(), self.from_station, self.to_station)
|
||||
check_user_url = 'https://kyfw.12306.cn/otn/login/checkUser'
|
||||
submit_station_url = 'https://kyfw.12306.cn/otn/leftTicket/submitOrderRequest'
|
||||
station_ticket = json.loads(myurllib2.get(select_url), encoding='utf-8')
|
||||
value = station_ticket['data']
|
||||
if value.__len__() is 0:
|
||||
print '当前车次查询为空...'
|
||||
print ('当前车次查询为空...')
|
||||
else:
|
||||
for i in value['result']:
|
||||
ticket_info = i.split('|')
|
||||
for j in range(20, 33):
|
||||
if ticket_info[j] != '' and ticket_info[j] != '无':
|
||||
print '车次: ' + ticket_info[3] + ' 始发车站: ' + value['map']['AOH'] + ' 终点站: ' + \
|
||||
value['map']['CSQ'] + ' ' + self.station_seat(j) + ': ' + ticket_info[j]
|
||||
print '正在尝试提交订票...'
|
||||
if ticket_info[j] != '' and ticket_info[j] != '无': # 过滤有效目标车次
|
||||
print ('车次: ' + ticket_info[3] + ' 始发车站: ' + value['map']['AOH'] + ' 终点站: ' + \
|
||||
value['map']['CSQ'] + ' ' + self.station_seat(j) + ': ' + ticket_info[j])
|
||||
print ('正在尝试提交订票...')
|
||||
data = dict(_json_att=None)
|
||||
check_user = json.loads(myurllib2.Post(check_user_url, data), encoding='utf-8')
|
||||
check_user_flag = check_user['data']['flag']
|
||||
if check_user_flag is True:
|
||||
print '尝试提交订单...'
|
||||
print ('尝试提交订单...')
|
||||
# 预定的请求参数,注意参数顺序
|
||||
# 注意这里为了防止secretStr被urllib.parse过度编码,在这里进行一次解码
|
||||
# 否则调用HttpTester类的post方法将会将secretStr编码成为无效码,造成提交预定请求失败
|
||||
|
@ -124,19 +159,23 @@ class select:
|
|||
('query_to_station_name', self.to_station), # 终点车站
|
||||
]
|
||||
submitResult = json.loads(myurllib2.Post(submit_station_url, data), encoding='utf-8')
|
||||
submit_data = submitResult['data']
|
||||
if submit_data == 'N':
|
||||
print '出票成功'
|
||||
else:
|
||||
print '出票失败'
|
||||
if 'data' in submitResult and submitResult['data']:
|
||||
if submitResult['data'] == 'N':
|
||||
print ('出票成功')
|
||||
return self.station_seat(j) # 车次信息,座位号
|
||||
else:
|
||||
print ('出票失败')
|
||||
elif 'messages' in submitResult and submitResult['messages']:
|
||||
print(submitResult['messages'])
|
||||
else:
|
||||
if check_user['massage']:
|
||||
print '用户检查失败:%s' % check_user['massage']
|
||||
if check_user['messages']:
|
||||
print ('用户检查失败:%s' % check_user['messages'])
|
||||
else:
|
||||
print '用户检查失败: %s' %check_user
|
||||
return submitResult
|
||||
print ('用户检查失败: %s' % check_user)
|
||||
else:
|
||||
print ('未查询到有效车次,重新查询中')
|
||||
|
||||
def getPassengerTicketStr(self, str):
|
||||
def getPassengerTicketStr(self, set_type):
|
||||
"""
|
||||
获取getPassengerTicketStr 提交对应的代号码
|
||||
:param str: 坐席
|
||||
|
@ -152,25 +191,80 @@ class select:
|
|||
'软卧': 4,
|
||||
'硬卧': 3,
|
||||
}
|
||||
return passengerTicketStr[str]
|
||||
self.set_type = str(passengerTicketStr[set_type.replace(' ', '')])
|
||||
|
||||
def checkOrderInfo(self, token):
|
||||
def ticket_type(self):
|
||||
"""订单票的类型,目前只考虑成人票,此方法暂时搁置,做备案"""
|
||||
ticket_type = {'adult': "1", 'child': "2", 'student': "3", 'disability': "4"}
|
||||
return ticket_type
|
||||
|
||||
def checkOrderInfo(self, user_info):
|
||||
"""
|
||||
检查支付订单,需要提交REPEAT_SUBMIT_TOKEN
|
||||
passengerTicketStr : 座位编号,0,票类型,乘客名,证件类型,证件号,手机号码,保存常用联系人(Y或N)
|
||||
oldPassengersStr: 乘客名,证件类型,证件号,乘客类型
|
||||
:return:
|
||||
"""
|
||||
passengerTicketStr = []
|
||||
oldPassengerStr = []
|
||||
passengerTicketStr.append(user_info[0]['passenger_id_type_code'])
|
||||
passengerTicketStr.append(user_info[0]['passenger_name'])
|
||||
passengerTicketStr.append(user_info[0]['passenger_type'])
|
||||
passengerTicketStr.append(user_info[0]['passenger_id_no'])
|
||||
passengerTicketStr.append(user_info[0]['mobile_no'])
|
||||
oldPassengerStr.append(user_info[0]['passenger_name'])
|
||||
oldPassengerStr.append(user_info[0]['passenger_type'])
|
||||
oldPassengerStr.append(user_info[0]['passenger_id_no'])
|
||||
oldPassengerStr.append(user_info[0]['passenger_type'])
|
||||
|
||||
checkOrderInfoUrl = 'https://kyfw.12306.cn/otn/confirmPassenger/checkOrderInfo'
|
||||
data = {
|
||||
'cancel_flag': 2,
|
||||
'bed_level_order_num': 000000000000000000000000000000,
|
||||
|
||||
'passengerTicketStr': self.set_type+',0,'+str(passengerTicketStr)+',N',
|
||||
'oldPassengerStr': str(oldPassengerStr)+'_',
|
||||
'tour_flag': 'dc',
|
||||
'REPEAT_SUBMIT_TOKEN': self.token,
|
||||
}
|
||||
checkOrderInfo = json.loads(myurllib2.Post(checkOrderInfoUrl, data))
|
||||
print (checkOrderInfo)
|
||||
if 'data' in checkOrderInfo and checkOrderInfo['data']['submitStatus'] is True:
|
||||
print ('车票提交通过,正在尝试排队')
|
||||
elif 'messages' in checkOrderInfo and checkOrderInfo['messages']:
|
||||
print (checkOrderInfo['messages'])
|
||||
|
||||
def getQueueCount(self):
|
||||
"""
|
||||
# 模拟查询当前的列车排队人数的方法
|
||||
# 返回信息组成的提示字符串
|
||||
:param token:
|
||||
:return:
|
||||
"""
|
||||
getQueueCountUrl = 'https://kyfw.12306.cn/otn/confirmPassenger/getQueueCount'
|
||||
data = {
|
||||
# 'train_date': 'Sun May 07 2017 00:00:00 GMT+0800',
|
||||
'train_date': self.ticketInfoForPassengerForm['queryLeftTicketRequestDTO']['train_date'],
|
||||
'train_no': self.ticketInfoForPassengerForm['queryLeftTicketRequestDTO']['train_no'],
|
||||
'stationTrainCode': self.ticketInfoForPassengerForm['queryLeftTicketRequestDTO']['station_train_code'],
|
||||
'seatType': self.set_type,
|
||||
'fromStationTelecode': self.ticketInfoForPassengerForm['queryLeftTicketRequestDTO']['from_station'],
|
||||
'toStationTelecode': self.ticketInfoForPassengerForm['queryLeftTicketRequestDTO']['to_station'],
|
||||
'leftTicket': self.ticketInfoForPassengerForm['leftTicketStr'],
|
||||
'purpose_codes': self.ticketInfoForPassengerForm['purpose_codes'],
|
||||
'train_location': self.ticketInfoForPassengerForm['train_location'],
|
||||
'REPEAT_SUBMIT_TOKEN': self.token,
|
||||
}
|
||||
print(data)
|
||||
getQueueCountResult = json.loads(myurllib2.Post(getQueueCountUrl, data))
|
||||
print(getQueueCountResult)
|
||||
|
||||
def main(self):
|
||||
token = self.getRepeatSubmitToken()
|
||||
self.submitOrderRequest()
|
||||
self.getPassengerDTOs(token)
|
||||
self.checkOrderInfo(token)
|
||||
set_type = self.submitOrderRequest()
|
||||
self.getPassengerTicketStr(set_type)
|
||||
self.getRepeatSubmitToken()
|
||||
user_info = self.getPassengerDTOs()
|
||||
self.checkOrderInfo(user_info)
|
||||
self.getQueueCount()
|
||||
|
||||
if __name__ == '__main__':
|
||||
a = select('上海', '北京')
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue