增加提交订单方法,增加订单排队方法

remotes/test12306/master
MR.wen 2017-05-22 22:11:12 +08:00
parent c43dc1bab4
commit 8d8b5ab1fb
3 changed files with 146 additions and 84 deletions

View File

@ -12,8 +12,8 @@
<component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/12306login$test.coverage" NAME="test Coverage Results" MODIFIED="1492940750689" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/12306login$damatuWeb.coverage" NAME="damatuWeb Coverage Results" MODIFIED="1492931635132" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/damatuCode" />
<SUITE FILE_PATH="coverage/12306login$run.coverage" NAME="run Coverage Results" MODIFIED="1495373855351" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/12306login$haha__1_.coverage" NAME="haha (1) Coverage Results" MODIFIED="1495373303310" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/12306login$run.coverage" NAME="run Coverage Results" MODIFIED="1495459646570" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/12306login$haha__1_.coverage" NAME="haha (1) Coverage Results" MODIFIED="1495460862020" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/12306login$haha.coverage" NAME="haha Coverage Results" MODIFIED="1492950969460" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/init" />
<SUITE FILE_PATH="coverage/12306login$select_ticket_info.coverage" NAME="select_ticket_info Coverage Results" MODIFIED="1495357851023" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/init" />
</component>
@ -38,10 +38,10 @@
<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="587">
<caret line="32" column="0" lean-forward="false" selection-start-line="32" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
<state relative-caret-position="815">
<caret line="46" column="26" lean-forward="true" selection-start-line="46" selection-start-column="6" selection-end-line="46" selection-end-column="26" />
<folding>
<element signature="e#707#718#0" expanded="true" />
<element signature="e#709#720#0" expanded="true" />
</folding>
</state>
</provider>
@ -50,11 +50,11 @@
<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="228">
<caret line="228" column="115" lean-forward="false" selection-start-line="228" selection-start-column="113" selection-end-line="228" selection-end-column="115" />
<state relative-caret-position="592">
<caret line="325" column="44" lean-forward="true" selection-start-line="325" selection-start-column="44" selection-end-line="325" selection-end-column="44" />
<folding>
<element signature="e#23#34#0" expanded="true" />
<element signature="e#7749#7895#0" expanded="false" />
<element signature="e#7834#7980#0" expanded="false" />
</folding>
</state>
</provider>
@ -63,8 +63,8 @@
<file leaf-file-name="login.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/init/login.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="492">
<caret line="130" column="12" lean-forward="true" selection-start-line="130" selection-start-column="12" selection-end-line="130" selection-end-column="12" />
<state relative-caret-position="2356">
<caret line="130" column="12" lean-forward="false" selection-start-line="130" selection-start-column="12" selection-end-line="130" selection-end-column="12" />
<folding />
</state>
</provider>
@ -73,8 +73,8 @@
<file leaf-file-name="damatuWeb.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/damatuCode/damatuWeb.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="568">
<caret line="114" column="67" lean-forward="true" selection-start-line="114" selection-start-column="67" selection-end-line="114" selection-end-column="67" />
<state relative-caret-position="2090">
<caret line="114" column="67" lean-forward="false" selection-start-line="114" selection-start-column="67" selection-end-line="114" selection-end-column="67" />
<folding />
</state>
</provider>
@ -84,7 +84,7 @@
<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>
@ -143,8 +143,7 @@
</component>
<component name="ProjectFrameBounds">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="2576" />
<option name="width" value="2570" />
<option name="height" value="1416" />
</component>
<component name="ProjectView">
@ -162,8 +161,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -206,6 +203,8 @@
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
@ -249,7 +248,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.run">
<component name="RunManager" selected="Python.haha (1)">
<configuration default="false" name="test" type="PythonConfigurationType" factoryName="Python" temporary="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -536,8 +535,8 @@
</list>
<recent_temporary>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="Python.run" />
<item index="1" class="java.lang.String" itemvalue="Python.haha (1)" />
<item index="0" class="java.lang.String" itemvalue="Python.haha (1)" />
<item index="1" class="java.lang.String" itemvalue="Python.run" />
<item index="2" class="java.lang.String" itemvalue="Python.select_ticket_info" />
<item index="3" class="java.lang.String" itemvalue="Python.haha" />
<item index="4" class="java.lang.String" itemvalue="Python.test" />
@ -590,19 +589,18 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="2576" height="1416" extended-state="6" />
<frame x="-8" y="0" width="2570" height="1416" extended-state="1" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1523101" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<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" />
<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="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<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="true" show_stripe_button="true" weight="0.27641654" 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="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.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="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="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" />
<window_info id="Data View" 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="4" side_tool="false" content_ui="tabs" />
@ -611,6 +609,7 @@
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<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="Ant Build" active="false" anchor="right" 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" />
</layout>
<layout-to-restore>
@ -648,15 +647,11 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file:///Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_LWPCookieJar.py" />
<entry file="file://$PROJECT_DIR$/init/login.py">
<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="false" />
<element signature="e#1259#1274#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -673,6 +668,7 @@
<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#7834#7980#0" expanded="false" />
</folding>
</state>
</provider>
@ -689,7 +685,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="5" column="38" lean-forward="false" selection-start-line="5" selection-start-column="38" selection-end-line="5" selection-end-column="38" />
<folding />
<folding>
<element signature="e#0#14#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -698,10 +696,7 @@
<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="false" />
<element signature="e#1259#1274#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -718,6 +713,7 @@
<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#7834#7980#0" expanded="false" />
</folding>
</state>
</provider>
@ -734,7 +730,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="5" column="38" lean-forward="false" selection-start-line="5" selection-start-column="38" selection-end-line="5" selection-end-column="38" />
<folding />
<folding>
<element signature="e#0#14#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -743,10 +741,7 @@
<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="false" />
<element signature="e#1259#1274#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -754,10 +749,7 @@
<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="false" />
<element signature="e#1259#1274#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -767,10 +759,7 @@
<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="false" />
<element signature="e#1259#1274#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -806,10 +795,7 @@
<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="false" />
<element signature="e#1259#1274#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -847,15 +833,15 @@
<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$/damatuCode/damatuWeb.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="568">
<caret line="114" column="67" lean-forward="true" selection-start-line="114" selection-start-column="67" selection-end-line="114" selection-end-column="67" />
<state relative-caret-position="2090">
<caret line="114" column="67" lean-forward="false" selection-start-line="114" selection-start-column="67" selection-end-line="114" selection-end-column="67" />
<folding />
</state>
</provider>
@ -880,8 +866,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/init/login.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="492">
<caret line="130" column="12" lean-forward="true" selection-start-line="130" selection-start-column="12" selection-end-line="130" selection-end-column="12" />
<state relative-caret-position="2356">
<caret line="130" column="12" lean-forward="false" selection-start-line="130" selection-start-column="12" selection-end-line="130" selection-end-column="12" />
<folding />
</state>
</provider>
@ -898,27 +884,34 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="477">
<caret line="178" column="8" lean-forward="false" selection-start-line="178" selection-start-column="8" selection-end-line="178" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://C:/Python27/Lib/random.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="520">
<caret line="886" column="0" lean-forward="false" selection-start-line="886" selection-start-column="0" selection-end-line="886" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/haha.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="587">
<caret line="32" column="0" lean-forward="false" selection-start-line="32" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
<state relative-caret-position="815">
<caret line="46" column="26" lean-forward="true" selection-start-line="46" selection-start-column="6" selection-end-line="46" selection-end-column="26" />
<folding>
<element signature="e#707#718#0" expanded="true" />
<element signature="e#709#720#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="228">
<caret line="228" column="115" lean-forward="false" selection-start-line="228" selection-start-column="113" selection-end-line="228" selection-end-column="115" />
<state relative-caret-position="592">
<caret line="325" column="44" lean-forward="true" selection-start-line="325" selection-start-column="44" selection-end-line="325" selection-end-column="44" />
<folding>
<element signature="e#23#34#0" expanded="true" />
<element signature="e#7749#7895#0" expanded="false" />
<element signature="e#7834#7980#0" expanded="false" />
</folding>
</state>
</provider>

View File

@ -29,14 +29,19 @@
# def __init__(self):
# pass
# def d(self):
# return a().b()
# # return a().b()
import time
import datetime
str = "2017052100:00:00"
m_time = time.mktime(time.strptime(str, "%Y%m%d%H:%M:%S"))
a_time = time.localtime(m_time)
print time.strftime("%a %b %d %Y %H:%M:%S", a_time)
# time_b = time.asctime("%a %b %d %H:%M:%S %Y", str)
# print time_b
#
# import datetime
#
# str = "2017052100:00:00"
# m_time = time.mktime(time.strptime(str, "%Y%m%d%H:%M:%S"))
# a_time = time.localtime(m_time)
# print time.strftime("%a %b %d %Y %H:%M:%S", a_time)
# # time_b = time.asctime("%a %b %d %H:%M:%S %Y", str)
# # print time_b
import random
# 1495457315834
# 428889054675
# 318250603668
print random.randint(1, 9)

View File

@ -1,6 +1,7 @@
# -*- coding=utf-8 -*-
import json
import datetime
import random
import re
import urllib
import sys
@ -15,8 +16,9 @@ class select:
self.order_request_params = {} # 订单提交时的参数
self.ticketInfoForPassengerForm = {} # 初始化当前页面参数
self.current_seats = {} # 席别信息
self.token = ''
self.set_type = ''
self.token = ""
self.set_type = ""
self.user_info = ""
def get_order_request_params(self):
return self.order_request_params
@ -139,12 +141,13 @@ class select:
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])
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过度编码在这里进行一次解码
@ -197,7 +200,7 @@ class select:
ticket_type = {'adult': "1", 'child': "2", 'student': "3", 'disability': "4"}
return ticket_type
def checkOrderInfo(self, user_info):
def checkOrderInfo(self):
"""
检查支付订单需要提交REPEAT_SUBMIT_TOKEN
passengerTicketStr : 座位编号,0,票类型,乘客名,证件类型,证件号,手机号码,保存常用联系人(Y或N)
@ -208,8 +211,8 @@ class select:
data = {
'cancel_flag': 2,
'bed_level_order_num': "000000000000000000000000000000",
'passengerTicketStr': self.set_type+',0,'+user_info[0]['passenger_id_type_code']+","+user_info[0]["passenger_name"]+","+user_info[0]['passenger_type']+","+user_info[0]['passenger_id_no']+","+user_info[0]['mobile_no']+',N',
'oldPassengerStr': user_info[0]['passenger_name']+","+user_info[0]['passenger_type']+","+user_info[0]['passenger_id_no']+","+user_info[0]['passenger_type']+'_',
'passengerTicketStr': self.set_type+',0,'+self.user_info[0]['passenger_id_type_code']+","+self.user_info[0]["passenger_name"]+","+self.user_info[0]['passenger_type']+","+self.user_info[0]['passenger_id_no']+","+self.user_info[0]['mobile_no']+',N',
'oldPassengerStr': self.user_info[0]['passenger_name']+","+self.user_info[0]['passenger_type']+","+self.user_info[0]['passenger_id_no']+","+self.user_info[0]['passenger_type']+'_',
'tour_flag': 'dc',
'REPEAT_SUBMIT_TOKEN': self.token,
}
@ -241,16 +244,18 @@ class select:
'leftTicket': self.get_ticketInfoForPassengerForm()['leftTicketStr'],
'purpose_codes': self.get_ticketInfoForPassengerForm()['purpose_codes'],
'train_location': self.get_ticketInfoForPassengerForm()['train_location'],
'REPEAT_SUBMIT_TOKEN': self.token,
'REPEAT_SUBMIT_TOKEN': self.get_token(),
}
getQueueCountResult = json.loads(myurllib2.Post(getQueueCountUrl, data))
if "status" in getQueueCountResult and getQueueCountResult["status"] is True:
if "countT" in getQueueCountResult["data"]:
countT = getQueueCountResult["data"]["countT"]
if int(countT) is 0:
print("排队成功, 当前余票还剩余 " + getQueueCountResult["data"]["ticket"]+ "")
print("排队成功, 当前余票还剩余:" + getQueueCountResult["data"]["ticket"]+ "")
print("提交订单中")
self.checkQueueOrder()
else:
print("正在排队,当前排队人数 " + str(countT) + "当前余票还剩余 " + getQueueCountResult["data"]["ticket"]+ "")
print("正在排队,当前排队人数:" + str(countT) + "当前余票还剩余:" + getQueueCountResult["data"]["ticket"]+ "")
else:
print("排队发现未知错误")
elif "messages" in getQueueCountResult and getQueueCountResult["messages"]:
@ -258,13 +263,72 @@ class select:
else:
print(getQueueCountResult["validateMessages"])
def checkQueueOrder(self):
"""
模拟提交订单是确认按钮参数获取方法还是get_ticketInfoForPassengerForm 中获取
:return:
"""
checkQueueOrderUrl = "https://kyfw.12306.cn/otn/confirmPassenger/confirmSingleForQueue"
data = {
"passengerTicketStr": self.set_type+',0,'+self.user_info[0]['passenger_id_type_code']+","+self.user_info[0]["passenger_name"]+","+self.user_info[0]['passenger_type']+","+self.user_info[0]['passenger_id_no']+","+self.user_info[0]['mobile_no']+',N',
"oldPassengerStr": self.user_info[0]['passenger_name']+","+self.user_info[0]['passenger_type']+","+self.user_info[0]['passenger_id_no']+","+self.user_info[0]['passenger_type']+'_',
"purpose_codes": self.get_ticketInfoForPassengerForm()["purpose_codes"],
"key_check_isChange": self.get_ticketInfoForPassengerForm()["key_check_isChange"],
"leftTicketStr": self.get_ticketInfoForPassengerForm()["leftTicketStr"],
"train_location": self.get_ticketInfoForPassengerForm()["train_location"],
"seatDetailType": "000", # 开始需要选择座位但是目前12306不支持自动选择作为那这个参数为默认
"roomType": "00", # 好像是根据一个id来判断选中的两种 第一种是00第二种是10但是我在12306的页面没找到该id目前写死是00不知道会出什么错
"dwAll": "N",
"REPEAT_SUBMIT_TOKEN": self.get_token(),
}
checkQueueOrderResult = json.loads(myurllib2.Post(checkQueueOrderUrl, data))
if "status" is checkQueueOrderResult and checkQueueOrderResult["status"]:
c_data = checkQueueOrderResult["data"] if checkQueueOrderResult["data"] in checkQueueOrderResult else {}
if 'submitStatus' in c_data and c_data['submitStatus']:
print("出票成功!")
else:
if 'errMsg' in c_data and c_data['errMsg']:
print("出票失败," + c_data['errMsg'] + "请重新选择。")
else:
print(c_data)
print('订票失败!很抱歉,请重试提交预订功能!')
elif "messages" in checkQueueOrderResult and checkQueueOrderResult["messages"]:
print("提交订单失败,错误信息: "+ checkQueueOrderResult["messages"])
else:
print("未知错误:" + checkQueueOrderResult["validateMessages"])
def queryOrderWaitTime(self):
"""
排队获取订单等待信息,每隔1秒请求一次最高请求次数为20次
:return:
"""
queryOrderWaitTimeUrl = "https://kyfw.12306.cn/otn/confirmPassenger/queryOrderWaitTime"
data = {
"random": "149545481029" + str(random.randint(1, 9)),
"tourFlag": "dc",
"REPEAT_SUBMIT_TOKEN": self.get_token(),
}
num = 1
while True:
num += 1
if num > 20:
print("订票失败!")
break
queryOrderWaitTimeResult = json.loads(myurllib2.Post(queryOrderWaitTimeUrl, data))
if "orderId" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["data"]["orderId"] != "null":
print ("恭喜您订票成功,订单号为:" + queryOrderWaitTimeResult["data"]["orderId"] + ", 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付")
break
print("订单提交中,请耐心等待")
time.sleep(1000)
def main(self):
set_type = self.submitOrderRequest()
self.getPassengerTicketStr(set_type)
self.getRepeatSubmitToken()
user_info = self.getPassengerDTOs()
self.checkOrderInfo(user_info)
self.user_info = self.getPassengerDTOs()
self.checkOrderInfo()
self.getQueueCount()
self.queryOrderWaitTime()
if __name__ == '__main__':
a = select('上海', '北京')