抽奖小程序
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()