예제 #1
0
def do_login():
    EasyHttp.removeCookies()
    login = Login()
    Log.v('正在登录...')
    result, msg = login.login(USER_NAME, USER_PWD, SELECT_AUTO_CHECK_CAPTHCA)
    EasyHttp.save_cookies(COOKIE_SAVE_ADDRESS)
    if not Utils.check(result, msg):
        return False,login
    Log.v('%s,登录成功' % msg)
    return True,login
예제 #2
0
def girl_of_the_night(love):
    Log.v('启动***休眠监控***线程')
    while 1:
        if love.get_my_love():
            break
        if love.get_login_status():
            status = check_re_login()
            if status:
                EasyHttp.save_cookies(COOKIE_SAVE_ADDRESS)
        time.sleep(HEART_BEAT_PER_REQUEST_TIME)

    Log.v('****** 12306 终止 ******')
예제 #3
0
def girl_of_the_night(love):
    Log.v('启动***休眠监控***线程')
    count = 0
    while 1:
        if love.get_my_love():
            break
        now = datetime.datetime.now()
        nowHour = now.hour
        if nowHour >= 23 or nowHour < 6:
            if count % HEART_BEAT_PER_REQUEST_TIME == 0:
                status = check_re_login()
                if status:
                    EasyHttp.save_cookies(COOKIE_SAVE_ADDRESS)
            time.sleep(HEART_BEAT_PER_REQUEST_TIME >> 1)
            count +=1
            continue
        # Log.e('非23点-6点,休眠%s秒'%(HEART_BEAT_PER_REQUEST_TIME << 1))
        time.sleep(HEART_BEAT_PER_REQUEST_TIME << 1)
예제 #4
0
파일: Query.py 프로젝트: zvrr/12306-1
    def loopQuery(trainDate,
                  fromStation,
                  toStation,
                  passengerType=PASSENGER_TYPE_ADULT,
                  trainsNo=[],
                  seatTypes=[SEAT_TYPE[key] for key in SEAT_TYPE],
                  PASSENGERS_ID=[],
                  leave_period=[],
                  POLICY_BILL=1,
                  timeInterval=QUERY_TICKET_REFERSH_INTERVAL,
                  heart_beat_request_time=3):
        count = 0
        base_query_url = queryUrls['query']['url']
        while True:
            nowTime, status = deadline.do_fix_time()
            if status:
                Log.v('当前时间:%s 处于23点到6点之间,12306处于维护状态,暂不处理下单业务' % nowTime)
                continue

            count += 1
            #标记是否登录已失效,heart_beat_request_time次发送一次心跳
            flag = True
            if count % heart_beat_request_time == 0:
                status = check_re_login()
                if not status:
                    flag = False
                else:
                    EasyHttp.save_cookies(COOKIE_SAVE_ADDRESS)
            Log.v('正在为您第%d次刷票' % count + ',当前时间为:%s' %
                  datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
            for ticketDetails in Query.querySpec(count, base_query_url,
                                                 trainDate, fromStation,
                                                 toStation, passengerType,
                                                 trainsNo, seatTypes,
                                                 PASSENGERS_ID, leave_period,
                                                 POLICY_BILL):
                if ticketDetails:
                    return flag, ticketDetails
            time.sleep(timeInterval)