import flask,json,time,redis,requests
from z_lib import tools
def my_redis(k,v=None):
r=redis.Redis(host='118.24.3.40', password='HK139bc&*',port=6379,db=0)
r.set(k,v)
def login(username,passwd):
url='http://api.nnzhp.cn/api/user/login'
data={'username':username,'passwd':passwd}
res=requests.post(url,data).json()
return res
# login(username='niuhanyang',passwd='aA123456')
def produce_choice(num):
username='niuhanyang'
passwd='aA123456'
res=login(username,passwd).get('login_info')
sign=res.get('sign')
userId=res.get('userId')
url='http://api.nnzhp.cn/api/product/choice'
data={'userid':userId,'sign':sign}
for i in range(num):
res=requests.get(url,params=data).json()
if res.get('error_code')==1099:
print('次数过多,')
key='choujiang:%s'%username
my_redis(key,0)
else:
print('抽奖信息',res)
produce_choice(3)