コード例 #1
0
ファイル: Submit.py プロジェクト: weaming/EasyTrain
 def _checkOrderInfo(self, passengersDetails, seatType, ticketTypeCodes=1):
     formData = {
         "cancel_flag":
         self.__ticket.ticketInfoForPassengerForm["orderRequestDTO"]
         ["cancel_flag"] or "2",
         "bed_level_order_num":
         self.__ticket.ticketInfoForPassengerForm["orderRequestDTO"]
         ["bed_level_order_num"] or "000000000000000000000000000000",
         "passengerTicketStr":
         TrainUtils.passengerTicketStrs(seatType, passengersDetails,
                                        ticketTypeCodes),
         "oldPassengerStr":
         TrainUtils.oldPassengerStrs(passengersDetails),
         "tour_flag":
         self.__ticket.ticketInfoForPassengerForm["tour_flag"] or "dc",
         "randCode":
         "",
         "whatsSelect":
         "1",
         "_json_att":
         "",
         "REPEAT_SUBMIT_TOKEN":
         self.__ticket.repeatSubmitToken,
     }
     jsonRet = EasyHttp.send(self._urlInfo["checkOrderInfo"], data=formData)
     return (
         jsonRet["status"],
         jsonRet["messages"],
         jsonRet["data"]["submitStatus"],
         jsonRet["data"]["errMsg"]
         if "errMsg" in jsonRet["data"] else "submit falied",
     )
コード例 #2
0
 def _checkOrderInfo(self, passengersDetails, seatType, ticketTypeCodes=1):
     formData = {
         'cancel_flag':
         self.__ticket.ticketInfoForPassengerForm['orderRequestDTO']
         ['cancel_flag'] or '2',
         'bed_level_order_num':
         self.__ticket.ticketInfoForPassengerForm['orderRequestDTO']
         ['bed_level_order_num'] or '000000000000000000000000000000',
         'passengerTicketStr':
         TrainUtils.passengerTicketStrs(seatType, passengersDetails,
                                        ticketTypeCodes),
         'oldPassengerStr':
         TrainUtils.oldPassengerStrs(passengersDetails),
         'tour_flag':
         self.__ticket.ticketInfoForPassengerForm['tour_flag'] or 'dc',
         'randCode':
         '',
         'whatsSelect':
         '1',
         '_json_att':
         '',
         'REPEAT_SUBMIT_TOKEN':
         self.__ticket.repeatSubmitToken,
     }
     jsonRet = EasyHttp.send(self._urlInfo['checkOrderInfo'], data=formData)
     submitStatus = ''
     errMsg = ''
     if jsonRet['data']:
         submitStatus = jsonRet['data']['submitStatus']
         errMsg = jsonRet['data']['errMsg'] if 'errMsg' in jsonRet[
             'data'] else 'submit falied'
     return jsonRet['status'], jsonRet['messages'], submitStatus, errMsg
コード例 #3
0
 def _confirmSingleOrGoForQueue(self, passengersDetails,choose_seat):
     formData = {
         'passengerTicketStr': TrainUtils.passengerTicketStrs(self.__ticket.seatType, passengersDetails, self.__ticket.ticketTypeCodes),
         'oldPassengerStr': TrainUtils.oldPassengerStrs(passengersDetails),
         'randCode': '',
         'purpose_codes': self.__ticket.ticketInfoForPassengerForm['purpose_codes'],
         'key_check_isChange': self.__ticket.ticketInfoForPassengerForm['key_check_isChange'],
         'leftTicketStr': self.__ticket.ticketInfoForPassengerForm['leftTicketStr'],
         'train_location': self.__ticket.ticketInfoForPassengerForm['train_location'],
         'choose_seats': ''.join(choose_seat) or '',
         'seatDetailType': '000',  # todo::make clear 000 comes from
         'whatsSelect': '1',
         'roomType': '00',  # todo::make clear this value comes from
         'dwAll': 'N',
         '_json_att': '',
         'REPEAT_SUBMIT_TOKEN': self.__ticket.repeatSubmitToken,
     }
     jsonRet = eHttp.send(self._urlInfo['confirmForQueue'], data=formData)
     return jsonRet['status'], jsonRet['messages'], jsonRet['data']['submitStatus'], jsonRet['data'][
         'errMsg'] if 'errMsg' in jsonRet['data'] else None
コード例 #4
0
ファイル: Submit.py プロジェクト: weaming/EasyTrain
 def _confirmSingleOrGoForQueue(self, passengersDetails):
     formData = {
         "passengerTicketStr":
         TrainUtils.passengerTicketStrs(self.__ticket.seatType,
                                        passengersDetails,
                                        self.__ticket.ticketTypeCodes),
         "oldPassengerStr":
         TrainUtils.oldPassengerStrs(passengersDetails),
         "randCode":
         "",
         "purpose_codes":
         self.__ticket.ticketInfoForPassengerForm["purpose_codes"],
         "key_check_isChange":
         self.__ticket.ticketInfoForPassengerForm["key_check_isChange"],
         "leftTicketStr":
         self.__ticket.ticketInfoForPassengerForm["leftTicketStr"],
         "train_location":
         self.__ticket.ticketInfoForPassengerForm["train_location"],
         "choose_seats":
         "".join(CHOOSE_SEATS) or "",
         "seatDetailType":
         "000",  # todo::make clear 000 comes from
         "whatsSelect":
         "1",
         "roomType":
         "00",  # todo::make clear this value comes from
         "dwAll":
         "N",
         "_json_att":
         "",
         "REPEAT_SUBMIT_TOKEN":
         self.__ticket.repeatSubmitToken,
     }
     jsonRet = EasyHttp.send(self._urlInfo["confirmForQueue"],
                             data=formData)
     return (
         jsonRet["status"],
         jsonRet["messages"],
         jsonRet["data"]["submitStatus"],
         jsonRet["data"]["errMsg"] if "errMsg" in jsonRet["data"] else None,
     )
コード例 #5
0
 def _checkOrderInfo(self, passengersDetails, seatType, ticketTypeCodes=1):
     url = r'https://kyfw.12306.cn/otn/confirmPassenger/checkOrderInfo'
     # self.__ticket.seatType = seatType
     # self.__ticket.ticketTypeCodes = ticketTypeCodes
     # self.passengerDetails = passengerDetails
     formData = {
         'cancel_flag':
         self.__ticket.ticketInfoForPassengerForm['orderRequestDTO']
         ['cancel_flag'] or '2',
         'bed_level_order_num':
         self.__ticket.ticketInfoForPassengerForm['orderRequestDTO']
         ['bed_level_order_num'] or '000000000000000000000000000000',
         'passengerTicketStr':
         TrainUtils.passengerTicketStrs(seatType, passengersDetails,
                                        ticketTypeCodes),
         'oldPassengerStr':
         TrainUtils.oldPassengerStrs(passengersDetails),
         'tour_flag':
         self.__ticket.ticketInfoForPassengerForm['tour_flag'] or 'dc',
         'randCode':
         '',
         'whatsSelect':
         '1',
         '_json_att':
         '',
         'REPEAT_SUBMIT_TOKEN':
         self.__ticket.repeatSubmitToken,
     }
     headers = {
         'User-Agent': FIREFOX_USER_AGENT,
         'Referer': r'https://kyfw.12306.cn/otn/confirmPassenger/initDc',
         'Connection': 'keep-alive',
     }
     response = NetUtils.post(self.__session,
                              url,
                              formData,
                              headers=headers).json()
     return response['status'], response['messages'], response['data']['submitStatus'], \
            response['data']['errMsg'] if 'errMsg' in response['data'] else 'submit falied'
コード例 #6
0
 def _confirmSingleOrGoForQueue(self, passengersDetails):
     url = r'https://kyfw.12306.cn/otn/confirmPassenger/confirmGoForQueue' if self.__ticket.tourFlag == TourFlag.GO_BACK \
         else r'https://kyfw.12306.cn/otn/confirmPassenger/confirmSingleForQueue'
     formData = {
         'passengerTicketStr':
         TrainUtils.passengerTicketStrs(self.__ticket.seatType,
                                        passengersDetails,
                                        self.__ticket.ticketTypeCodes),
         'oldPassengerStr':
         TrainUtils.oldPassengerStrs(passengersDetails),
         'randCode':
         '',
         'purpose_codes':
         self.__ticket.ticketInfoForPassengerForm['purpose_codes'],
         'key_check_isChange':
         self.__ticket.ticketInfoForPassengerForm['key_check_isChange'],
         'leftTicketStr':
         self.__ticket.ticketInfoForPassengerForm['leftTicketStr'],
         'train_location':
         self.__ticket.ticketInfoForPassengerForm['train_location'],
         'choose_seats':
         '',  # todo::how to choose seats
         'seatDetailType':
         '000',  # todo::make clear 000 comes from
         'whatsSelect':
         '1',
         'roomType':
         '00',  # todo::make clear this value comes from
         'dwAll':
         'N',
         '_json_att':
         '',
         'REPEAT_SUBMIT_TOKEN':
         self.__ticket.repeatSubmitToken,
     }
     headers = {
         'User-Agent':
         FIREFOX_USER_AGENT,
         'Referer':
         r'https://kyfw.12306.cn/otn/confirmPassenger/{}'.format(
             'initWc' if self.__ticket.tourFlag ==
             TourFlag.GO_BACK else 'initDc'),
         'Connection':
         'keep-alive',
         r'Accept':
         r'application/json, text/javascript, */*; q=0.01',
         'Accept-Encoding':
         'gzip, deflate, br',
         'Accept-Language':
         'en-US,en;q=0.5',
         'Content-Type':
         'application/x-www-form-urlencoded; charset=UTF-8',
         'Host':
         'kyfw.12306.cn',
         'X-Requested-With':
         'XMLHttpRequest',
     }
     response = NetUtils.post(self.__session,
                              url,
                              data=formData,
                              headers=headers).json()
     return response['status'], response['messages'], response['data'][
         'submitStatus'], response['data'][
             'errMsg'] if 'errMsg' in response['data'] else None