Ejemplo n.º 1
0
def test(cid):
    while 1:
        try:
            ret = requests.get(
                f'http://www.huomao.com/eventBox/isHaveEventTreasure?cid={cid}',
                cookies=Common.generate_cookies(uid),
                proxies={
                    'http': random.choice(ip_pool)
                }).json()
            print(ret)
            if ret['status']:
                print(ret)
                treasure_id = ret['data']['id']
                open_time = int(ret['data']['open_time'])
                time.sleep(open_time)
                for i in range(10):
                    ret = requests.get(
                        f'http://www.huomao.com/EventBox/getEventTreasure?treasure_id={treasure_id}&cid={cid}',
                        cookies=Common.generate_cookies(uid),
                        proxies={'http': random.choice(ip_pool)})
                    print(ret.json())
                time.sleep(0.2)
            time.sleep(100)
            time.sleep(random.randint(20, 40))
        except:
            print('error')
Ejemplo n.º 2
0
Archivo: 11.py Proyecto: github4n/work
def get_ssbx(open_time, cid, treasure_id):
    time.sleep(open_time)
    ret = requests.get(
        f'{url}/EventBox/getEventTreasure?treasure_id={treasure_id}&cid={cid}',
        cookies=Common.generate_cookies(uid),
        proxies=proxies)
    print(ret.json())
Ejemplo n.º 3
0
def bx(data):
    try:
        data = json.loads(data)
        if data.get('code') == '300002':
            cid = data['gift']['channel']['cid']
            print(cid, '有普通宝箱')
            ret = requests.get(f'{url}/channels/isHaveTreasure?cid={cid}', proxies=proxies).json()
            for key, value in ret.items():
                if key != 'count':
                    treasure_key = value['key']
                    countdown = int(value['countdown'])
                    t = threading.Thread(target=get_bx, args=(countdown, cid, treasure_key))
                    t.start()
        elif data.get('code') == '888888':
            cid = data['allStation']['bannerWords']['targetUrl']
            print(cid, '有赛事宝箱')
            ret = requests.get(f'{url}/eventBox/isHaveEventTreasure?cid={cid}',
                               cookies=Common.generate_cookies(uid),
                               proxies=proxies).json()
            if ret['status']:
                treasure_id = ret['data']['id']
                open_time = int(ret['data']['open_time'])
                t = threading.Thread(target=get_ssbx, args=(open_time, cid, treasure_id))
                t.start()
    except Exception as e:
        print(e)
Ejemplo n.º 4
0
 def test1(self):
     self.url = '/PrivateShow/joinShow'
     self.data = {}
     # 主播房间号
     self.data['cid'] = '10'
     res = requests.get(DOMAIN + self.url, params=self.data, cookies=Common.generate_cookies(5253)).text
     Common.try_json(res)
Ejemplo n.º 5
0
def banker(uid, **kw):
    data = {
        'period': '111111',  # 期号
        'opt_type':
        200001,  # 选项类型 normal,normal_3,normal_4,normal_5,money_line,ball
        'coin_type': 'free_bean',  # 货币类型仙豆free_bean,猫豆cat_bean
        # 'punter': 'banker',  # bet:普通下注,'banker':坐庄, 'buyer':买庄
        'banker_odds': 2,  # 赔率
        'chose': 1,  # 坐庄选项
        'amount': 1000,
        # 'third_id': 0,
    }
    for key, value in kw.items():
        data[key] = value
    post_data = Common.form_single_dict(data)
    res = requests.post(URL + '/guessnew/banker?bet_room_number=1&refer=web',
                        data=post_data,
                        cookies=Common.generate_cookies(uid))
    try:
        res = res.json()
        res_info = f'用户{uid}坐庄数据\n{data}返回{res}\n'
        logging.info(res_info)
        if res['status'] == 'success':
            return res['data']['banker']['order_id']
    except ValueError:
        logging.error(res.text)
        return False
Ejemplo n.º 6
0
 def test3(self):
     self.url = '/PrivateShow/endShowByUid'
     self.data = {}
     # 主播房间号
     self.data['cid'] = '10'
     res = requests.get(DOMAIN + self.url, params=self.data, cookies=Common.generate_cookies(1522)).text
     Common.try_json(res)
Ejemplo n.º 7
0
 def test4(self):
     self.url = '/PrivateShow/changeStatus'
     self.data = {}
     # 主播房间号
     self.data['cid'] = '14'
     res = requests.get(DOMAIN + self.url, params=self.data, cookies=Common.generate_cookies(1522)).text
     Common.try_json(res)
Ejemplo n.º 8
0
Archivo: 11.py Proyecto: github4n/work
def get_bx(countdown, cid, treasure_key):
    time.sleep(countdown)
    ret = requests.get(
        f'{url}/chatnew/getTreasure?cid={cid}&treasure_key={treasure_key}',
        cookies=Common.generate_cookies(uid),
        proxies=proxies)
    print(ret.json())
Ejemplo n.º 9
0
def getc():
    try:
        res = requests.post(url1, cookies=Common.generate_cookies(1522))
        # 期数
        period = res.json()['item_maps']['period']
        # 选项集合
        res_items = res.json()['item_maps']['items']
        logging.info('参数{}{}'.format(period, res_items))
        return period, res_items
    except Exception as e:
        logging.exception(e)
        logging.exception(res.text)
Ejemplo n.º 10
0
def bet(uid, **kw):
    data = {
        'bet': {
            0: {
                'period': '111111',  # 期号
                'opt_type': 200001,  # 选项类型
                'coin_type': 'free_bean',  # 货币类型仙豆free_bean,猫豆cat_bean
                'punter': 'bet',  # bet:普通下注,'banker':坐庄, 'buyer':买庄
                'chose': {  # 下注选项
                    # 0: {'chose': 1, 'amount': 100, 'now_odds': 0},
                    # 1: {'chose': 1, 'amount': 100, 'now_odds': 0},
                },
            },
        }
    }
    for key, value in kw.items():
        data['bet'][0][key] = value
    post_data = Common.form_single_dict(data)
    requests.post(URL + '/guessnew/betMore?bet_room_number=1&refer=web',
                  data=post_data,
                  cookies=Common.generate_cookies(uid))
    # 轮询
    for i in range(10):
        ret = requests.get(URL + '/guessnew/bettingRes',
                           cookies=Common.generate_cookies(uid)).text
        if Common.is_json(ret):
            ret = json.loads(ret)
            if ret['code'] == 0:
                res_info = f'用户{uid}下注成功:数据{data}返回{ret}'
                logging.info(res_info)
                return ret
            else:
                res_info = f'用户{uid}下注失败:数据{data}返回{ret}'
                logging.info(res_info)
        else:
            logging.error(ret)
            return False
        time.sleep(1)
    return False
Ejemplo n.º 11
0
def change_banker(uid, period, id, banker_odds='', type_='revoke'):
    data = {
        'period': period,  # 期号
        'id': id,
        'banker_odds': banker_odds,
    }
    res = requests.post(URL + '/guessnew/changeBanker/' + type_,
                        data=data,
                        cookies=Common.generate_cookies(uid))
    if type_ == 'revoke':
        logging.info(f'撤庄{res.json()}')
    else:
        logging.info(f'修改庄{res.json()}')
    return res.json()
Ejemplo n.º 12
0
def bet1(uid, period, res_items):
    try:
        item = random.choice(list(res_items))
        # item = 'bet14'
        odds = res_items[item]['odds']
        # 期号 赔率 选项 下注额
        data = dict(period=period, odds=odds, item=item, amount=10, cid=cid)
        res = requests.post(url2,
                            data=data,
                            cookies=Common.generate_cookies(uid))
        logging.info('下注{}'.format(data))
        logging.info(res.json())
    except Exception as e:
        logging.exception(e)
Ejemplo n.º 13
0
def register(request):
    name = request.POST.get('name_zc')
    res = user.register(name)
    # response = HttpResponse(json.dumps(res))
    response = JsonResponse(res)
    cookies = Common.generate_cookies(res.get('uid', 1522))
    for key, value in cookies.items():
        response.set_cookie(key,
                            value,
                            domain='.huomaotv.com.cn',
                            max_age=86400)
    response.set_cookie('user_frontloginstat',
                        1,
                        domain='.huomaotv.com.cn',
                        max_age=86400 * 7)
    return response
Ejemplo n.º 14
0
def mn_login(request):
    uid = request.POST.get('uid')
    cookies = Common.generate_cookies(uid)
    response = HttpResponse('')
    for key, value in cookies.items():
        # response.set_cookie(key, value, domain='.huomaotv.com.cn', max_age=86400)
        response.set_cookie(key,
                            value,
                            domain='.huomaotv.com.cn',
                            max_age=86400)
    # response.set_cookie('user_frontloginstat', 1, domain='.huomaotv.com.cn', max_age=86400 * 7)
    response.set_cookie('user_frontloginstat',
                        1,
                        domain='.huomaotv.com.cn',
                        max_age=86400 * 7)
    return response
Ejemplo n.º 15
0
Archivo: lib.py Proyecto: github4n/work
def req(self):
    # exit()
    report_data['test_sum'] += 1
    # 判断环境
    if 'api' in self._testMethodName:
        # api 加密token
        self.data = Common.encrypt(self.data)
        cookies = None
        domain = getattr(self, 'domain', domain_api)
    elif 'admin' in self._testMethodName:
        cookies = ADMIN_COOKIES
        domain = getattr(self, 'domain', domain_admin)
    else:
        cookies = Common.generate_cookies(self.user)
        domain = getattr(self, 'domain', domain_web)

    self.resquest_url = ''.join(
        [domain, self.
         url, '?', parse.urlencode(self.data)] if parse.
        urlencode(self.data) else [domain, self.url])
    logger_test_api.info(f'请求数据:{self.data}请求url:{self.resquest_url}')

    # 判断请求方式
    headers = {'X-Requested-With': 'XMLHttpRequest'}
    if self.method == 'get':
        res = requests.get(domain + self.url,
                           params=self.data,
                           cookies=cookies,
                           headers=headers)
    elif self.method == 'post':
        res = requests.post(domain + self.url,
                            data=self.data,
                            cookies=cookies,
                            headers=headers)
    else:
        res = False
    try:
        real_res = res.json()
    except Exception:
        try:
            real_res = json.loads(res.text[1:-1])
        except Exception:
            real_res = res.text
    logger_test_api.info(f'返回{real_res}')
    # 判断请求结果是否包含预期结果
    result = assert_dict_in(self.exp_res, real_res) and res.status_code == 200

    if result:
        logger_test_api.info(f'{self._testMethodName}验证成功')
        if not hasattr(self, 'ver'):
            report_data['test_success'] += 1
        elif hasattr(self, 'ver') and self.ver():
            report_data['test_success'] += 1
            logger_test_api.info(f'{self._testMethodName}二次验证成功')
        else:
            report_data['test_failed'] += 1
            logger_test_api.error(f'{self._testMethodName}二次验证失败')
            self.assertTrue(False, '二次验证失败')
    else:
        report_data['test_failed'] += 1
        self.info = f'用例{self._testMethodName},失败\n预期:{self.exp_res}\n实际:{real_res}\n实际json:{json.dumps(real_res)}'
        logger_test_api.error(self.info)
        self.assertFalse(self.info)
Ejemplo n.º 16
0
def bet2(uid):
    try:
        res = requests.post(url1, cookies=Common.generate_cookies(uid))
        logging.info('join{}'.format(res.json()))
    except Exception as e:
        logging.exception(e)
Ejemplo n.º 17
0
 def test(self,i):
     res = requests.get(DOMAIN + self.url, params = self.data, cookies = Common.generate_cookies(i))
     Common.try_json(res.text)
Ejemplo n.º 18
0
# -*- coding: utf-8 -*-
# Date   : 2018/7/24 13:54
# Author : lixingyun
# Description :
from huomao.user import User
from huomao.bag import Bag
from decimal import *
import requests
from huomao.common import Common, REDIS_INST
from huomao.money import MoneyClass
import time
# Bag.add_bag(1522,90001)

# User.add_noble_card(34052, 3, 2, 1)

#
# t = Bag.get_dmk(1522,90011)

item = 1000
uid = 35482

MoneyClass.set_money(uid, item / 1000, 0)

REDIS_INST.delete('hm_new_guess_active_recharge_joins_tag')
# url = 'http://lxy.new.huomaotv.com.cn/badgeexchange/exchangePay?room_number=0&refer=web'
url = 'http://lxy.new.huomaotv.com.cn/Smallgame/exchangePay?room_number=0&refer=web'
ret = requests.post(url,
                    data=dict(item=item),
                    cookies=Common.generate_cookies(uid))
print(ret.text)