Ejemplo n.º 1
0
    def checkTicketSecretStr(self, ticket_json, train, seat_type):
        if not ticket_json.has_key("data"):
            return 0, ""

        for w in ticket_json["data"]:
            if w["queryLeftNewDTO"]["station_train_code"] == train:
                seat = TicketFunctions.getTicketCount(w["queryLeftNewDTO"]["yp_info"])
                if seat[seat_type] != 0:
                    # 如果有票就返回这趟车的余票数据
                    return 1, w["secretStr"]

        return 0, ""
Ejemplo n.º 2
0
    def testHasTicket(self, ticket_json, train, seat_type):
        if not ticket_json.has_key("data"):
            return 0, ""

        for w in ticket_json["data"]:
            if w["queryLeftNewDTO"]["station_train_code"] == train:
                seat = TicketFunctions.getTicketCount(w["queryLeftNewDTO"]["yp_info"])
                if seat[seat_type] >= self.minTicketSubmit:
                    # 如果有票就返回这趟车的余票数据
                    return 1, w, seat[seat_type]

        return 0, "", 0
Ejemplo n.º 3
0
    def checkTicketSecretStr(self, ticket_json, train, seat_type):
        if not ticket_json.has_key('data'):
            return 0, ""

        for w in ticket_json['data']:
            if w['queryLeftNewDTO']['station_train_code'] == train:
                seat = TicketFunctions.getTicketCount(
                    w['queryLeftNewDTO']['yp_info'])
                if seat[seat_type] != 0:
                    # 如果有票就返回这趟车的余票数据
                    return 1, w['secretStr']

        return 0, ""
Ejemplo n.º 4
0
    def testHasTicket(self, ticket_json, train, seat_type):
        if not ticket_json.has_key('data'):
            return 0, ""

        for w in ticket_json['data']:
            if w['queryLeftNewDTO']['station_train_code'] == train:
                seat = TicketFunctions.getTicketCount(
                    w['queryLeftNewDTO']['yp_info'])
                if seat[seat_type] >= self.minTicketSubmit:
                    # 如果有票就返回这趟车的余票数据
                    return 1, w, seat[seat_type]

        return 0, "", 0
Ejemplo n.º 5
0
    def __init__(self, config, session, proxy=None):
        '''
        self.proxies = {'http':'http://192.168.108.237:8888', 
            'https':'http://192.168.108.237:8888'
        }
        
        self.proxies = {'http':'http://127.0.0.1:8888', 
            'https':'http://127.0.0.1:8888'
        }
        '''

        self.stations = []

        self.orderInfo = {
            'byDate': '2014-01-31',
            'secretStr': '',
            'station_train_code': '',
            'train_no': '',
            'from_station_name': '',
            'from_station_telecode': '',
            'to_station_name': '',
            'to_station_telecode': '',
            'location_code': '',
            'key_check_ischange': '',
            'leftTicketStr': '',
            'isAsync': ''
        }

        self.host_ips = [
            '219.145.161.13', '121.205.7.44', 'kyfw.12306.cn',
            '113.207.63.142', '219.145.161.11', '42.202.148.46',
            '163.177.242.54'
        ]

        self.randCodePath = 'login.png'

        self.host_ip_index = 0

        self.passengerTicketStr = ""
        self.oldPassengerStr = ''

        self.base_url = "https://kyfw.12306.cn/otn/"
        self.login_url = "https://kyfw.12306.cn/otn/login/loginAysnSuggest"

        self.getPassenger_url = "https://kyfw.12306.cn/otn/confirmPassenger/getPassengerDTOs"
        self.initDc_url = "https://kyfw.12306.cn/otn/confirmPassenger/initDc"

        self.autoSubmitOrderRequest_url = "https://kyfw.12306.cn/otn/confirmPassenger/autoSubmitOrderRequest"
        self.confirmSingleForQueueAsys_url = 'https://kyfw.12306.cn/otn/confirmPassenger/confirmSingleForQueueAsys'
        self.getQueueCountAsync_url = 'https://kyfw.12306.cn/otn/confirmPassenger/getQueueCountAsync'
        self.checkRandCodeAnsyn_url = 'https://kyfw.12306.cn/otn/passcodeNew/checkRandCodeAnsyn'
        self.AsynSugguestUrl = "https://kyfw.12306.cn/otn/login/loginAysnSuggest"
        self.loginRandRequestUrl = "https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew.do?module=login&rand=sjrand"
        self.orderRandRequestUrl = "https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew.do?module=login&rand=sjrand&0.5445713368916163"

        self.User_Agent = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.48 Safari/537.36'
        self.cookie_filepath = 'cookie.txt'

        self.headers = {
            'User-Agent': self.User_Agent,
            'X-Requested-With': 'XMLHttpRequest',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6',
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Connection': 'keep-alive',
            'Host': 'kyfw.12306.cn',
            'Referer': 'https://kyfw.12306.cn/otn/leftTicket/init'
        }

        self.headers_img = {
            'User-Agent': self.User_Agent,
            'Accept': 'image/webp,*/*;q=0.8',
            'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6',
            'Connection': 'keep-alive',
            'Referer': 'https://kyfw.12306.cn/otn/leftTicket/init'
        }

        self.stationInit()

        self.session = session
        self.username = config['username']
        self.password = config['password']
        self.ifUseAutoRandCode = config['ifUseAutoRandCode']
        if config['ifUseAutoRandCode'] == "yes":
            self.ifUseAutoRandCode = True
        else:
            self.ifUseAutoRandCode = False

        # train_filter_type 和   train_filter二选一
        # 如果train_filter为空,则通过train_filter_type过滤
        #train_filter_type = ['G', 'T', 'K', 'D']
        self.train_filter_type = config['train_filter_type']
        self.train_filter = config['train_filter']
        self.seat_filter = config['seat_filter']
        self.date_filter = config['date_filter']
        self.current_date_index = 0

        self.orderInfo['from_station_name'] = config['from_station_name']
        self.orderInfo['to_station_name'] = config['to_station_name']
        self.orderInfo[
            'from_station_telecode'] = TicketFunctions.getTelcodeFromName(
                self.orderInfo['from_station_name'])
        self.orderInfo[
            'to_station_telecode'] = TicketFunctions.getTelcodeFromName(
                self.orderInfo['to_station_name'])
        self.idList = config['idList']

        self.updateTrainDate()

        self.newPassengers = config['newPassengers']
        for p in self.newPassengers:
            if not p['id'] in self.idList:
                self.idList.append(p['id'])

        self.minTicketSubmit = len(self.idList)

        self.passengerList = []
Ejemplo n.º 6
0
    def __init__(self, config, session, proxy=None):
        """
        self.proxies = {'http':'http://192.168.108.237:8888', 
            'https':'http://192.168.108.237:8888'
        }
        
        self.proxies = {'http':'http://127.0.0.1:8888', 
            'https':'http://127.0.0.1:8888'
        }
        """

        self.stations = []

        self.orderInfo = {
            "byDate": "2014-01-31",
            "secretStr": "",
            "station_train_code": "",
            "train_no": "",
            "from_station_name": "",
            "from_station_telecode": "",
            "to_station_name": "",
            "to_station_telecode": "",
            "location_code": "",
            "key_check_ischange": "",
            "leftTicketStr": "",
            "isAsync": "",
        }

        self.host_ips = [
            "219.145.161.13",
            "121.205.7.44",
            "kyfw.12306.cn",
            "113.207.63.142",
            "219.145.161.11",
            "42.202.148.46",
            "163.177.242.54",
        ]

        self.randCodePath = "login.png"

        self.host_ip_index = 0

        self.passengerTicketStr = ""
        self.oldPassengerStr = ""

        self.base_url = "https://kyfw.12306.cn/otn/"
        self.login_url = "https://kyfw.12306.cn/otn/login/loginAysnSuggest"

        self.getPassenger_url = "https://kyfw.12306.cn/otn/confirmPassenger/getPassengerDTOs"
        self.initDc_url = "https://kyfw.12306.cn/otn/confirmPassenger/initDc"

        self.autoSubmitOrderRequest_url = "https://kyfw.12306.cn/otn/confirmPassenger/autoSubmitOrderRequest"
        self.confirmSingleForQueueAsys_url = "https://kyfw.12306.cn/otn/confirmPassenger/confirmSingleForQueueAsys"
        self.getQueueCountAsync_url = "https://kyfw.12306.cn/otn/confirmPassenger/getQueueCountAsync"
        self.checkRandCodeAnsyn_url = "https://kyfw.12306.cn/otn/passcodeNew/checkRandCodeAnsyn"
        self.AsynSugguestUrl = "https://kyfw.12306.cn/otn/login/loginAysnSuggest"
        self.loginRandRequestUrl = "https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew.do?module=login&rand=sjrand"
        self.orderRandRequestUrl = (
            "https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew.do?module=login&rand=sjrand&0.5445713368916163"
        )

        self.User_Agent = (
            "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.48 Safari/537.36"
        )
        self.cookie_filepath = "cookie.txt"

        self.headers = {
            "User-Agent": self.User_Agent,
            "X-Requested-With": "XMLHttpRequest",
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6",
            "Accept": "application/json, text/javascript, */*; q=0.01",
            "Connection": "keep-alive",
            "Host": "kyfw.12306.cn",
            "Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
        }

        self.headers_img = {
            "User-Agent": self.User_Agent,
            "Accept": "image/webp,*/*;q=0.8",
            "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6",
            "Connection": "keep-alive",
            "Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
        }

        self.stationInit()

        self.session = session
        self.username = config["username"]
        self.password = config["password"]
        self.ifUseAutoRandCode = config["ifUseAutoRandCode"]
        if config["ifUseAutoRandCode"] == "yes":
            self.ifUseAutoRandCode = True
        else:
            self.ifUseAutoRandCode = False

        # train_filter_type 和   train_filter二选一
        # 如果train_filter为空,则通过train_filter_type过滤
        # train_filter_type = ['G', 'T', 'K', 'D']
        self.train_filter_type = config["train_filter_type"]
        self.train_filter = config["train_filter"]
        self.seat_filter = config["seat_filter"]
        self.date_filter = config["date_filter"]
        self.current_date_index = 0

        self.orderInfo["from_station_name"] = config["from_station_name"]
        self.orderInfo["to_station_name"] = config["to_station_name"]
        self.orderInfo["from_station_telecode"] = TicketFunctions.getTelcodeFromName(
            self.orderInfo["from_station_name"]
        )
        self.orderInfo["to_station_telecode"] = TicketFunctions.getTelcodeFromName(self.orderInfo["to_station_name"])
        self.idList = config["idList"]

        self.updateTrainDate()

        self.newPassengers = config["newPassengers"]
        for p in self.newPassengers:
            if not p["id"] in self.idList:
                self.idList.append(p["id"])

        self.minTicketSubmit = len(self.idList)

        self.passengerList = []