def sendAutoSubmitOrderRequest(self): """ 请求下单接口 :return: """ urls = self.session.urls["autoSubmitOrderRequest"] data = self.data_par() autoSubmitOrderRequestResult = self.session.httpClint.send(urls, data) if autoSubmitOrderRequestResult and \ autoSubmitOrderRequestResult.get("status", False) and\ autoSubmitOrderRequestResult.get("httpstatus", False) == 200: requestResultData = autoSubmitOrderRequestResult.get("data", {}) if requestResultData: result = requestResultData.get("result", "") ifShowPassCode = requestResultData.get("ifShowPassCode", "N") ifShowPassCodeTime = int( requestResultData.get("ifShowPassCodeTime", "1000")) / float(1000) print(ticket.AUTO_SUBMIT_ORDER_REQUEST_C) g = getQueueCountAsync( session=self.session, train_no=self.train_no, stationTrainCode=self.stationTrainCode, fromStationTelecode=self.query_from_station_name, toStationTelecode=self.query_to_station_name, leftTicket=self.leftTicket, set_type=self.set_type, users=len(self.session.ticke_peoples), station_dates=self.train_date, passengerTicketStr=self.passengerTicketStr, oldPassengerStr=self.oldPassengerStr, result=result, ifShowPassCodeTime=ifShowPassCodeTime, ) g.sendGetQueueCountAsync() if ifShowPassCode == "Y": # 如果需要验证码 print(u"需要验证码") print(u"正在使用自动识别验证码功能") for i in range(3): randCode = getRandCode( is_auto_code=True, auto_code_type=_get_yaml()["auto_code_type"]) checkcode = checkRandCodeAnsyn(self.session, randCode, "") if checkcode == 'TRUE': print(u"验证码通过,正在提交订单") data['randCode'] = randCode break else: print(u"验证码有误, {0}次尝试重试".format(i + 1)) print(u"验证码超过限定次数3次,放弃此次订票机会!") g.sendGetQueueCountAsync() else: print(ticket.AUTO_SUBMIT_ORDER_REQUEST_F) if autoSubmitOrderRequestResult.get("messages", ""): print("".join(autoSubmitOrderRequestResult.get("messages", ""))) elif autoSubmitOrderRequestResult.get("validateMessages", ""): print("".join( autoSubmitOrderRequestResult.get("validateMessages", "")))
def sendAutoSubmitOrderRequest(self): """ 请求下单接口 :return: """ urls = self.session.urls["autoSubmitOrderRequest"] data = self.data_par() autoSubmitOrderRequestResult = self.session.httpClint.send(urls, data) if autoSubmitOrderRequestResult and \ autoSubmitOrderRequestResult.get("status", False) and\ autoSubmitOrderRequestResult.get("httpstatus", False) == 200: requestResultData = autoSubmitOrderRequestResult.get("data", {}) if requestResultData: result = requestResultData.get("result", "") ifShowPassCode = requestResultData.get("ifShowPassCode", "N") ifShowPassCodeTime = int(requestResultData.get("ifShowPassCodeTime", "1000")) / float(1000) print(ticket.AUTO_SUBMIT_ORDER_REQUEST_C) g = getQueueCountAsync(session=self.session, train_no=self.train_no, stationTrainCode=self.stationTrainCode, fromStationTelecode=self.query_from_station_name, toStationTelecode=self.query_to_station_name, leftTicket=self.leftTicket, set_type=self.set_type, users=len(self.session.ticke_peoples), station_dates=self.train_date, passengerTicketStr=self.passengerTicketStr, oldPassengerStr=self.oldPassengerStr, result=result, ifShowPassCodeTime=ifShowPassCodeTime, ) if ifShowPassCode == "Y": # 如果需要验证码 print(u"需要验证码") print(u"正在使用自动识别验证码功能") for i in range(3): randCode = getRandCode(is_auto_code=True, auto_code_type=_get_yaml()["auto_code_type"]) checkcode = checkRandCodeAnsyn(self.session, randCode, "") if checkcode == 'TRUE': print(u"验证码通过,正在提交订单") data['randCode'] = randCode break else: print (u"验证码有误, {0}次尝试重试".format(i + 1)) print(u"验证码超过限定次数3次,放弃此次订票机会!") g.sendGetQueueCountAsync() else: print(ticket.AUTO_SUBMIT_ORDER_REQUEST_F) if autoSubmitOrderRequestResult.get("messages", ""): print("".join(autoSubmitOrderRequestResult.get("messages", ""))) elif autoSubmitOrderRequestResult.get("validateMessages", ""): print("".join(autoSubmitOrderRequestResult.get("validateMessages", "")))