Пример #1
0
def get_lottery_msg(request):
    current_date = GetDate().get_base_date_forward_six()
    obj_pro_predict = KillPredict.objects.filter(
        kill_predict_date=current_date)
    #print "obj_pro",obj_pro_predict
    return render_to_response('test.html',
                              {"obj_pro_predict": obj_pro_predict})
Пример #2
0
def get_kill_predict_msg(request):
    current_date = GetDate().get_base_date_forward_six()
    pk_logger.info("current_date report:%s", current_date)
    obj_pro_kill_predict = KillPredict.objects.filter(
        kill_predict_date=current_date)
    #print "obj_pro_kill_predict",obj_pro_kill_predict
    return render_to_response('test.html',
                              {"obj_pro_kill_predict": obj_pro_kill_predict})
Пример #3
0
def delete_kill_predict_current_date(request):

    current_date = GetDate().get_base_date_forward_six()
    KillPredict.objects.filter(kill_predict_date=current_date).delete()
    obj_pro_predict = KillPredict.objects.filter(
        kill_predict_date=current_date)

    PredictLottery.objects.filter(lottery_date=current_date).delete()
    return render_to_response('test.html',
                              {"obj_pro_predict": obj_pro_predict})
Пример #4
0
def get_purchase_list_99_define(interval):
    current_date = GetDate().get_base_date_forward_six()
    lotterys = PredictLottery.objects.filter(
        lottery_date=current_date).order_by("-lottery_id")
    print "len(lotterys)", len(lotterys)
    last_lottery = 0
    for lottery in lotterys:
        last_lottery = lottery
        break
    if last_lottery == 0:
        return 0, '', '', '', 1
    predict_lottery_id = last_lottery.lottery_id + 1

    delete_number_list = interval["in_number_ids"].split(',')
    # pk_logger.info("=---------------------delete_number_list:%s",delete_number_list)

    purchase_number_list = ''
    lottery_number_all = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
    last_lottery_id_list = delete_number_list

    if last_lottery_id_list[0] == last_lottery_id_list[1]:
        purchase_number_list = purchase_number_list + (str(-1))
    else:
        temp = lottery_number_all[:]
        for last_lottery_id in last_lottery_id_list:
            temp.remove(last_lottery_id)
        temp_list = ''
        for i in temp:
            temp_list = temp_list + str(i) + '|'
        purchase_number_list = purchase_number_list + (temp_list[:-1])

    purchase_number_list = purchase_number_list + (',')
    purchase_number_list = purchase_number_list + (str(-1))
    purchase_number_list = purchase_number_list + (',')
    purchase_number_list = purchase_number_list + (str(-1))
    purchase_number_list = purchase_number_list + (',')
    purchase_number_list = purchase_number_list + (str(-1))
    purchase_number_list = purchase_number_list + (',')

    if last_lottery_id_list[0] == last_lottery_id_list[1]:
        purchase_number_list = purchase_number_list + (str(-1))
    else:
        temp = lottery_number_all[:]
        for last_lottery_id in last_lottery_id_list:
            temp.remove(last_lottery_id)
        temp_list = ''
        for i in temp:
            temp_list = temp_list + str(i) + '|'
        purchase_number_list = purchase_number_list + (temp_list[:-1])

    xiazhu_index_list = [0, 0, 0, 0, 0]
    purchase_number_list_desc = str(purchase_number_list)
    purchase_mingci_number = 1
    print "purchase_number_list:", purchase_number_list
    return predict_lottery_id, purchase_number_list, purchase_number_list_desc, xiazhu_index_list, purchase_mingci_number
Пример #5
0
def get_purchase_list_99_auto(interval):

    current_date = GetDate().get_base_date_forward_six()
    lotterys = PredictLottery.objects.filter(
        lottery_date=current_date).order_by("-lottery_id")
    print "len(lotterys)", len(lotterys)
    last_lottery = 0
    for lottery in lotterys:
        last_lottery = lottery
        break
    if last_lottery == 0:
        return 0, '', '', '', 1
    # predict_lottery_id = current_date + str(last_lottery.lottery_id).zfill(4)
    predict_lottery_id = last_lottery.lottery_id + 1

    purchase_number_list = ''
    xiazhu_index_list = []
    lottery_number_all = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
    last_lottery_id_list = last_lottery.lottery_number.split(',')
    if last_lottery_id_list[0] == last_lottery_id_list[1]:
        purchase_number_list = purchase_number_list + (str(-1))
    else:
        temp = lottery_number_all[:]
        temp.remove(last_lottery_id_list[0])
        temp.remove(last_lottery_id_list[1])
        temp_list = ''
        for i in temp:
            temp_list = temp_list + str(i) + '|'
        purchase_number_list = purchase_number_list + (temp_list[:-1])

    purchase_number_list = purchase_number_list + (',')
    purchase_number_list = purchase_number_list + (str(-1))
    purchase_number_list = purchase_number_list + (',')
    purchase_number_list = purchase_number_list + (str(-1))
    purchase_number_list = purchase_number_list + (',')
    purchase_number_list = purchase_number_list + (str(-1))
    purchase_number_list = purchase_number_list + (',')

    if last_lottery_id_list[3] == last_lottery_id_list[4]:
        purchase_number_list = purchase_number_list + (str(-1))
    else:
        temp = lottery_number_all[:]
        temp.remove(last_lottery_id_list[3])
        temp.remove(last_lottery_id_list[4])
        temp_list = ''
        for i in temp:
            temp_list = temp_list + str(i) + '|'
        purchase_number_list = purchase_number_list + (temp_list[:-1])

    xiazhu_index_list = [0, 0, 0, 0, 0]
    purchase_number_list_desc = str(purchase_number_list)
    purchase_mingci_number = 1
    print "purchase_number_list:", purchase_number_list
    return predict_lottery_id, purchase_number_list, purchase_number_list_desc, xiazhu_index_list, purchase_mingci_number
Пример #6
0
def get_open_lottery(request):
    current_date = GetDate().get_base_date_forward_six()
    result_info = {}

    obj_pro_lottery = PredictLottery.objects.filter(
        lottery_date=current_date).order_by("-lottery_id")
    if len(obj_pro_lottery) == 0:
        result_info['last_lottery_id'] = 0
        pass
    else:
        result_info['last_lottery_id'] = int(obj_pro_lottery[0].lottery_id)
        result_info['lottery_number'] = obj_pro_lottery[0].lottery_number

    return render_to_response('test.html',
                              {"obj_pro_predict": obj_pro_lottery})
Пример #7
0
def get_predict_model_value():
    # current_date = time.strftime('%Y%m%d',time.localtime(time.time()))
    current_date = GetDate().get_base_date_forward_six()
    predicts = KillPredict.objects.filter(
        kill_predict_date=current_date).order_by("-lottery_id")
    lottery_id = 0
    kill_predict_number = 0
    xiazhu_money = 0
    if len(predicts) == 0:
        #print "predicts is null"
        pk_logger.debug("predicts is null")
    else:
        lottery_id = predicts[0].lottery_id
        kill_predict_number = predicts[0].kill_predict_number
        xiazhu_money = predicts[0].xiazhu_money
    return lottery_id, kill_predict_number, xiazhu_money
Пример #8
0
def get_predict_kill_and_save(interval):
    #爬取下一期predict

    if interval["auto_flag"] == "true":
        predict_lottery_id, purchase_number_list, purchase_number_list_desc, xiazhu_index_list, purchase_mingci_number = get_purchase_list_99_auto(
            interval)
    else:
        predict_lottery_id, purchase_number_list, purchase_number_list_desc, xiazhu_index_list, purchase_mingci_number = get_purchase_list_99_define(
            interval)

    if predict_lottery_id != 0:
        #更新models
        pk_logger.info("save predict_lottery_id : %s", predict_lottery_id)
        pk_logger.info("save purchase_number_list : %s", purchase_number_list)
        current_date = GetDate().get_base_date_forward_six()
        save_predict_time = datetime.datetime.now().strftime("%Y%m%d %H:%M:%S")

        xiazhu_money = 1
        kill_predicts = KillPredict.objects.filter(
            lottery_id=int(predict_lottery_id))
        #保存
        if 1:
            p = KillPredict(kill_predict_date=current_date,
                            save_predict_time=save_predict_time,
                            lottery_id=int(predict_lottery_id),
                            kill_predict_number=purchase_number_list,
                            kill_predict_number_desc=purchase_number_list_desc,
                            percent_all_list_desc='',
                            predict_total=0,
                            target_total=0,
                            predict_accuracy=0,
                            predict_number_all=xiazhu_index_list,
                            xiazhu_money=xiazhu_money,
                            gain_money=0,
                            is_xiazhu=0,
                            input_money=0,
                            xiazhu_nums=purchase_mingci_number)
            p.save()
            print "predict save ok"
        else:
            print "exsist predict_lottery_id:", predict_lottery_id
Пример #9
0
def get_predict(request):
    current_date = GetDate().get_base_date_forward_six()
    result_info = {}
    # lotterys = KillPredict.objects.filter(lottery_date=current_date)
    #获取预测的lottery id 和预测的号码
    obj_pro_predict = KillPredict.objects.filter(
        kill_predict_date=current_date).order_by("-lottery_id")
    if len(obj_pro_predict) == 0:
        pass
    else:
        result_info['predict_lottery_id'] = int(obj_pro_predict[0].lottery_id)
        result_info['predict_number_list'] = obj_pro_predict[
            0].kill_predict_number
        result_info['predict_number_list_desc'] = obj_pro_predict[
            0].kill_predict_number_desc
        result_info['xiazhu_money'] = obj_pro_predict[0].xiazhu_money
        result_info['save_predict_time'] = obj_pro_predict[0].save_predict_time
        result_info['purchase_number_money_index'] = obj_pro_predict[
            0].predict_number_all
        #print "predict lottery_id:",obj_pro_predict[0].lottery_id

        #pk_logger.info("predict lottery_id: %d",obj_pro_predict[0].lottery_id)
        #pk_logger.info("kill_predict_number: %s",obj_pro_predict[0].kill_predict_number)
        #print "kill_predict_number:",obj_pro_predict[0].kill_predict_number

    obj_pro_lottery = PredictLottery.objects.filter(
        lottery_date=current_date).order_by("-lottery_id")
    if len(obj_pro_lottery) == 0:
        result_info['last_lottery_id'] = 0
        pass
    else:
        result_info['last_lottery_id'] = int(obj_pro_lottery[0].lottery_id)
        result_info['lottery_number'] = obj_pro_lottery[0].lottery_number
        #print "last lottery_id:",obj_pro_lottery[0].lottery_id
        #pk_logger.info("last lottery_id: %d",obj_pro_lottery[0].lottery_id)
    return HttpResponse(json.dumps(result_info),
                        content_type="application/json")
Пример #10
0
def start_purchase(purchase_element_list, interval, buy_money_list):
    #计算历史总盈利
    gain_all_money = 0
    # current_date = time.strftime('%Y%m%d',time.localtime(time.time()))
    current_date = GetDate().get_base_date_forward_six()

    sum_objects_predict = KillPredict.objects.filter(
        kill_predict_date=current_date)
    for gain in sum_objects_predict:
        if (gain.gain_money):
            gain_all_money = gain_all_money + gain.gain_money
    #print "gain_all_money:",gain_all_money
    pk_logger.info("calc gain_all_money:%d", gain_all_money)
    #开始购买
    try:
        interval['purchase_driver'] = reload_pk10_driver(
            interval['purchase_driver'], interval)
        purchase_driver = interval['purchase_driver']

        #time.sleep(1)
        purchase_driver.find_element_by_xpath(
            '//*[@id="lt_cf_clear"]/a').click()
        time.sleep(1)
        purchase_driver.find_element_by_xpath(
            '/html/body/div[3]/div[2]/div/div/div/div/div[3]/button[2]').click(
            )
        time.sleep(1)
        print "delete ok"

        try:
            money_index = 0
            for purchase_element in purchase_element_list:

                pk_logger.info("start purchase purchase_element:%s",
                               purchase_element)
                pk_logger.info("current xaizhu money:%d",
                               int(buy_money_list[money_index]))
                sub_element = purchase_driver.find_element_by_xpath(
                    purchase_element)
                #追加下注
                sub_element.click()
                time.sleep(1)
                set_money_element = purchase_driver.find_element_by_xpath(
                    '//*[@id="lt_sel_times"]')
                set_money_element.send_keys(
                    str(int(buy_money_list[money_index])))
                time.sleep(1)
                #添加注单
                confirm_button = purchase_driver.find_element_by_xpath(
                    '//*[@id="lt_sel_insert"]')
                confirm_button.click()
                time.sleep(1)
                money_index = money_index + 1

            #投注
            commit_button = purchase_driver.find_element_by_xpath(
                '//*[@id="lt_buy"]')
            commit_button.click()
            time.sleep(1)
            pk_logger.info("commit ok")
            #确定
            submit_button = purchase_driver.find_element_by_xpath(
                '/html/body/div[3]/div[2]/div/div/div/div/div[3]/button[2]')
            #submit_button = purchase_driver.find_element_by_xpath('//*[@id="myLayer_1"]/tbody/tr/td/div[3]/a[2]')
            submit_button.click()
            time.sleep(1)
            pk_logger.info("purchase ok")
            return True
        except:
            pk_logger.error("purchase driver error time is invalid!!!")
            return False
    except:
        pk_logger.error("reload pk10 error !!!")
        return False
Пример #11
0
def delete_kill_predict_current_date_restart():

    current_date = GetDate().get_base_date_forward_six()
    KillPredict.objects.filter(kill_predict_date=current_date).delete()
    PredictLottery.objects.filter(lottery_date=current_date).delete()
Пример #12
0
def start_purchase(purchase_element_list, interval, buy_money):
    #计算历史总盈利
    gain_all_money = 0
    # current_date = time.strftime('%Y%m%d',time.localtime(time.time()))
    current_date = GetDate().get_base_date_forward_six()

    sum_objects_predict = KillPredict.objects.filter(
        kill_predict_date=current_date)
    for gain in sum_objects_predict:
        if (gain.gain_money):
            gain_all_money = gain_all_money + gain.gain_money
    #print "gain_all_money:",gain_all_money
    pk_logger.info("calc gain_all_money:%d", gain_all_money)
    #开始购买
    try:
        interval['purchase_driver'] = reload_pk10_driver(
            interval['purchase_driver'], interval)
        purchase_driver = interval['purchase_driver']

        #设置倍数
        purchase_driver.find_element_by_xpath(
            '/html/body/div/div[2]/div[4]/div/div[4]/div[5]/input').clear()
        time.sleep(1)
        print "clear money ok"

        purchase_driver.find_element_by_xpath(
            '/html/body/div/div[2]/div[4]/div/div[4]/div[5]/input').send_keys(
                str(buy_money))
        time.sleep(1)

        try:
            pk_logger.info("current xaizhu money:%d", int(buy_money))
            for purchase_element in purchase_element_list:

                #pk_logger.info("start purchase purchase_element:%s",purchase_element)
                purchase_driver.find_element_by_xpath(purchase_element).click()
                #time.sleep(1)
            time.sleep(1)

            #添加到投注
            purchase_driver.find_element_by_xpath(
                '/html/body/div/div[2]/div[4]/div/div[4]/div[5]/span/button[1]'
            ).click()
            print "add touzhu "
            time.sleep(1)

            #确认投注    一键投注
            #purchase_driver.find_element_by_xpath('/html/body/div/div[2]/div[4]/div/div[4]/div[5]/span/button[2]').click()
            purchase_driver.find_element_by_xpath(
                '/html/body/div/div[2]/div[4]/div/div[4]/div[6]/div[2]/span[1]/button'
            ).click()
            print "add confirm"
            # print purchase_driver.page_source
            time.sleep(2)

            #提交
            purchase_driver.find_element_by_class_name(
                'ngdialog-buttons').find_element_by_tag_name('button').click()
            time.sleep(3)
            pk_logger.info("purchase ok")
            return True
        except:
            pk_logger.error("purchase driver error time is invalid!!!")
            return False
    except:
        pk_logger.error("reload pk10 error !!!")
        return False
Пример #13
0
def get_predict_kill_and_save(interval):
    #购买流程
    purchase_flag_confirm = True
    while (purchase_flag_confirm):
        purchase_flag_minute = int(time.strftime("%M", time.localtime())) % 10
        purchase_flag_second = int(time.strftime("%S", time.localtime()))
        if 1:
            result_info = get_server_request_info()
            if 1:
                #判断是否获取接口数据正确
                if result_info:
                    last_id = int(result_info['last_lottery_id'])
                    predict_id = int(result_info['predict_lottery_id'])
                    pk_logger.info("last_id,predict_id:%d, %d", last_id,
                                   predict_id)
                    try:
                        purchase_driver = interval['purchase_driver']
                        avolid = int(
                            str(
                                purchase_driver.find_element_by_xpath(
                                    '/html/body/div/div[2]/div[3]/div/div/div[3]/p[2]'
                                ).text).split(':')[-1])
                        pk_logger.info("------web minute is  ......:%d",
                                       avolid)
                    except:
                        pk_logger.info("------get web minute error  ......:%d",
                                       avolid)
                        avolid = 0
                    #判断是否成功拿到predict
                    if predict_id > last_id and avolid < 41 and avolid > 15:
                        #判断是否是最新一期并且之前未购买,防止重复购买
                        current_predict = KillPredict.objects.get(
                            lottery_id=predict_id)
                        current_is_xiazhu = current_predict.is_xiazhu

                        pk_logger.info("--------current_is_xiazhu:%d",
                                       current_is_xiazhu)
                        if current_is_xiazhu == 0:
                            #通过购买历史获取倍数
                            current_date = GetDate().get_base_date()
                            killpredicts = KillPredict.objects.filter(
                                kill_predict_date=current_date).order_by(
                                    "lottery_id")

                            front_multiple = 1
                            back_multiple = 1
                            is_xiazhu_list = []
                            front_multiple_list = []
                            front_hit_list = []
                            back_multiple_list = []
                            back_hit_list = []
                            purchase_rule_list = interval[
                                "in_mulitiple_number_list"]
                            pk_logger.info(
                                "-----------------purchase_rule_list:%s",
                                purchase_rule_list)
                            if len(killpredicts) > 1:
                                if interval["rule_id"] == 1:
                                    for killpredict in killpredicts:
                                        front_multiple_list.append(
                                            killpredict.front_multiple)
                                        front_hit_list.append(
                                            killpredict.front_hit)
                                        is_xiazhu_list.append(
                                            killpredict.is_xiazhu)

                                    front_multiple_list = front_multiple_list[:
                                                                              -1]
                                    front_hit_list = front_hit_list[:-1]
                                    is_xiazhu_list = is_xiazhu_list[:-1]
                                    #2期中断
                                    #front_multiple = get_multiple_front_back(front_multiple_list, front_hit_list, is_xiazhu_list, purchase_rule_list )
                                    if interval["in_continue"] == 1:
                                        front_multiple = get_multiple_front_back_continue(
                                            front_multiple_list,
                                            front_hit_list, is_xiazhu_list,
                                            purchase_rule_list)
                                    else:
                                        front_multiple = get_multiple_front_back(
                                            front_multiple_list,
                                            front_hit_list, is_xiazhu_list,
                                            purchase_rule_list)

                                else:
                                    for killpredict in killpredicts:
                                        back_multiple_list.append(
                                            killpredict.back_multiple)
                                        back_hit_list.append(
                                            killpredict.back_hit)
                                        is_xiazhu_list.append(
                                            killpredict.is_xiazhu)

                                    back_multiple_list = back_multiple_list[:
                                                                            -1]
                                    back_hit_list = back_hit_list[:-1]
                                    is_xiazhu_list = is_xiazhu_list[:-1]
                                    #back_multiple = get_multiple_front_back(back_multiple_list, back_hit_list, is_xiazhu_list, purchase_rule_list )
                                    if interval["in_continue"] == 1:
                                        back_multiple = get_multiple_front_back_continue(
                                            back_multiple_list, back_hit_list,
                                            is_xiazhu_list, purchase_rule_list)
                                    else:
                                        back_multiple = get_multiple_front_back(
                                            back_multiple_list, back_hit_list,
                                            is_xiazhu_list, purchase_rule_list)

                            pk_logger.info("last front_multiple:%s",
                                           front_multiple)
                            pk_logger.info("last back_multiple:%s",
                                           back_multiple)

                            purchase_number_list = result_info[
                                'predict_number_list']
                            #获取投注倍数索引
                            purchase_number_money_index = [
                                int(front_multiple), 0, 0, 0,
                                int(back_multiple)
                            ]

                            in_money = interval['in_money']
                            pk_logger.info("start purchase, xiazhu money:%d",
                                           in_money)
                            rule_id = interval['rule_id']
                            #获取购买元素列表个数
                            purchase_element_list, buy_money = get_xiazhu_message_cai99(
                                purchase_number_list,
                                purchase_number_money_index, in_money, rule_id)
                            pk_logger.info("start purchase, buy money:%d",
                                           buy_money)
                            if len(purchase_element_list) > 0:
                                # 购买
                                if buy_money > 0 and len(
                                        purchase_element_list) > 1:
                                    purchase_result = start_purchase(
                                        purchase_element_list, interval,
                                        buy_money)
                                    input_money = len(
                                        purchase_element_list) * 1
                                    if purchase_result:
                                        pk_logger.info(
                                            "purchase sucess!, input money:%s",
                                            input_money)
                                        pk_logger.info(
                                            "-----purchase sucess!, front_multiple:%d",
                                            front_multiple)
                                        pk_logger.info(
                                            "-----purchase sucess!, back_multiple:%d",
                                            back_multiple)
                                        time.sleep(3)
                                        p = KillPredict.objects.get(
                                            lottery_id=predict_id)
                                        p.is_xiazhu = 1
                                        p.input_money = input_money
                                        p.front_multiple = front_multiple
                                        p.back_multiple = back_multiple
                                        p.save()
                                        pk_logger.info(
                                            "save xiazhu args sucess!:%s", p)
                                        purchase_driver = interval[
                                            'purchase_driver']
                                        time.sleep(5)
                                    else:
                                        pk_logger.info("purchase faild!")
                                else:
                                    p = KillPredict.objects.get(
                                        lottery_id=predict_id)
                                    p.is_xiazhu = 0
                                    p.input_money = 0
                                    p.front_multiple = front_multiple
                                    p.back_multiple = back_multiple
                                    p.save()
                                    pk_logger.info(
                                        "----no purchase save xiazhu  multiple sucess!"
                                    )
                                    time.sleep(5)

                            else:
                                #print 'no element in purchase_element_list '
                                pk_logger.info(
                                    "no element in purchase_element_list  or stop purchase"
                                )

                            purchase_flag_confirm = False
                        else:
                            pk_logger.info(
                                "----------wait time until predict ok!")
                            time.sleep(5)
                            purchase_flag_confirm = False
                    else:
                        pk_logger.info(
                            "wait time until shahao message save ok")
                        time.sleep(2)
                else:
                    pk_logger.info("get server interface error!")
                    purchase_flag_confirm = False
                    time.sleep(1)
        else:
            time.sleep(1)
            purchase_flag_confirm = False
            #print "purchase time is no region!"
            pk_logger.info("purchase time is no region!")