zoukankan      html  css  js  c++  java
  • 抽奖小程序

    1、先部署,部署文档,QQ上搜索抽奖部署

    # 2、http://doc.nnzhp.cn/index.php?s=/5&page_id=17
    #     这个抽奖接口,每天只能抽奖3次,而且必须先登录才能抽奖
    #
    #     1、写一个函数,让他自动抽奖
    #         1、先登录,获取到sign
    #         2、然后再调用抽奖接口
    #         3、抽奖接口每天只能抽3次,抽奖的时候如果提示你抽奖次数已经用完
    #         那么你就连上redis,修改抽奖次数
    import requests,redis
    user='zhourui'
    pwd='Aa123456'
    def reg():
        url='http://api.nnzhp.cn/api/user/user_reg'
        data={'username':user,'pwd':pwd,'cpwd':pwd}
        req=requests.post(url,data)
        print(req.json())
    def login():
        url='http://api.nnzhp.cn/api/user/login'
        data={'username':user,'passwd':pwd}
        req=requests.post(url,data)
        print(req.json())
        return(req.json())
    def draw():
        url='http://api.nnzhp.cn/api/product/choice'
        data={'userid':login_info['login_info']['userId'],'sign':login_info['login_info']['sign']}
        req=requests.get(url,params=data)
        print(req.json())
        return(req.json())
    def record():
        url='http://api.nnzhp.cn/api/user/win_record'
        data={'userid':login_info['login_info']['userId'],'sign':login_info['login_info']['sign']}
        req=requests.get(url,params=data)
        print(req.json())
    def de_redis(k):
        r = redis.Redis(host='118.24.3.40', password='HK139bc&*', port=6379, db=1)
        r.delete(k)
    reg()
    login_info=login()
    print('----------------------------------本次抽奖记录---------------------------------')
    for i in range(10):
        try:
            if  draw()['product_info']['count']==3:
                de_redis('choujiang:%s' % user)
        except Exception as e:
            de_redis('choujiang:%s'%user)
            draw()
    print('----------------------------------抽奖历史记录---------------------------------')
    record()
  • 相关阅读:
    React Native 安卓 程序运行报错: React Native version mismatch(转载)
    RN用蓝牙接入热敏打印机和智能电子秤(转载)
    安装加密用包
    React Native 调用 Web3(1.x) 的正确姿势
    Unable to resolve module crypto
    点击<tr>表格行元素进行跳转
    Phonegap环境配置
    登录记住密码功能的实现
    php+sqlserver实现分页效果
    php日期格式转换
  • 原文地址:https://www.cnblogs.com/ruijie/p/10670197.html
Copyright © 2011-2022 走看看