农夫山泉小程序抽奖(可云函数) 1.27更新
本帖最后由 水墨青云 于 2022-1-27 15:38 编辑参考农夫山泉小程序抽奖完成每日任务更新了https://www.52pojie.cn/thread-1580177-1-1.html (出处: 吾爱破解论坛)
感谢@蜀黍说不能太长
PS:抽奖功能 发送的抽奖码经常更新,所以抽奖功能可能失效较快
还有查询抽奖次数 经常抽风,得到的次数是0次。在手机上抓包也是这样...就很奇怪小程序怎么正确获取抽奖次数的
****
2022.1.27
修复检查金虎水情况
2022.1.26
增加 一键让用户2将全部道具赠送给用户1
代码所在行数为 212-275 291
2022.1.25
增加 抽奖时先查询抽奖次数
修改 抽奖body (这个又变了)
增加 获取用户名
支持多账号,3个账户即可相互助力
扩大两次助力之间的间隔,防止出现助力人数太多的错误
****
微信小程序 农夫山泉好水旺财虎年吉祥
自己抓包加参考,改变了内容,添加了抽奖和查询当前拥有的卡片,抽奖次数不知道怎么回事经常获得的是0次,就删掉了
支持云函数,腾讯云函数请使用python3.6, python3.7不成功,好像是找不到‘requests’模块
可以pushplus微信推送
默认抽奖(182)、查询道具(184)和推送(117)已经被注释掉了,需要的可以自己填写apitoken和token后将注释去掉
查询道具因为我只抽到3个,所以只有3个道具对应的代码,哪位大佬提供下 虎头帽 和 金虎水 对应的代码
代码如下:
# -*- coding: utf8 -*-
import requests
from time import sleep
from json import dumps
from random import uniform
#做任务必填
#最好填3个user_id,正好形成循环,没那么多就空着apitoken(可不填)用于抽奖,查询道具
all_user = [
{
"user_id": "WXoSLos5****1600711680",
"apitoken": ""
},{
"user_id": "WXoSLos5****1600711680",
"apitoken": ""
},{
"user_id": "WXoSLos5****1600711680",
"apitoken": ""
}
]
#可不填
#用于抽奖,查询道具 (可能会过期,没试过)填3个,没有的就空着
#微信推送
token = "0d402ce7d83f4ea08a28fa421d1cc481"
#############################################
#自己的ID
user_id = ""
#助力的ID
assistance_user_id = []
#抽奖用
apitoken = ""
header = {
"actcode": "ACT39912445427025182721600711680",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.17(0x1800112a) NetType/WIFI Language/zh_CN"
}
#日志推送至微信
def Send(senddata):
url = "http://www.pushplus.plus/send/"
data = {
"token": token,
"title": "农夫山泉任务",
"content": senddata
}
headers = {'Content-Type':'application/json'}
res = requests.post(url,data=dumps(data).encode(encoding='utf-8'),headers=headers)
print(res.text)
#任务请求
def task(url,data):
res = requests.post(url,headers=header,data=data).json()
if res['success'] :
return(])
else:
return(])
#执行任务
def do_task():
#任务列表 助力1 助力2 签到 访问商店 观看视频 领取助力奖励
tasklist = [{
"url": "https://nongfuwaterpro.kifa.site/api/v1/goldtiger/specialuserassistance",
"data": {
"user_id": user_id,
"assistance_user_id": assistance_user_id
}
}, {
"url": "https://nongfuwaterpro.kifa.site/api/v1/goldtiger/usersign",
"data": {
"user_id": user_id
}
}, {
"url": "https://nongfuwaterpro.kifa.site/api/v1/goldtiger/userviewshop",
"data": {
"user_id": user_id
}
}, {
"url": "https://nongfuwaterpro.kifa.site/api/v1/goldtiger/userviewvideo",
"data": {
"url": "https://cdn.geement.com/sfiles/NongFu/JinHuWater/video.mov",
"user_id": user_id
}
},{
"url": "https://nongfuwaterpro.kifa.site/api/v1/goldtiger/specialuserassistance",
"data": {
"user_id": user_id,
"assistance_user_id": assistance_user_id
}
}, {
"url": "https://nongfuwaterpro.kifa.site/api/v1/goldtiger/completeassistancetask",
"data": {
"user_id": user_id
}
}]
for i in tasklist:
result = task(i['url'],i['data'])
if result:
print(f"任务成功:{result}")
else:
print(f"任务失败:{result}")
sleep(float('%.1f' % uniform(1,3)))
#详细检查助力结果中有无金虎水,需登录apitoken
def check2():
url = "https://gateway.jmhd8.com/geement.act.api/api/v1/act/win/goods/simple?act_codes=ACT39912445427025182721600711680%2CACT39912460803343646721600711680%2CACT39912477585928355841600711680"
header['apitoken'] =apitoken
res = requests.get(url,headers=header).json()
if res['success'] :
for luckprop in res['data']:
if '金虎水' in luckprop['win_goods_name']:
return
return
else:
return ]
#检查助力结果中有无金虎水
def check():
url = f"https://nongfuwaterpro.kifa.site/api/v1/goldtiger/assistancewinlogs?user_id={user_id}"
res = requests.get(url,headers=header).json()
if res['success'] :
for luckprop in res['data']:
if '金虎水' in luckprop['win_goods_name']:
return
return
else:
return ]
#执行检查结果(choose: True 详细检查 False 粗略检查)
def do_check(choose):
if choose:
result = check2()
else:
result = check()
if result:
if result :
tiger = f"{getusername()}:助力结果中有金虎水,请查看"
Send(tiger)
else:
tiger = "助力结果中没有金虎水"
print(f"检查成功:{tiger}")
else:
print(f"检查失败:{result}")
#获取抽奖次数
def get_luck_draw_count():
url = "https://gateway.jmhd8.com/geement.act.api/api/v1/lottery/surplus/count"
data = {
"user_id": user_id
}
res = requests.get(url,headers=header,data=data).json()
if res['success'] :
return ,res['data']]
else:
return ]
#抽奖
def luck(data):
url = "https://gateway.jmhd8.com/geement.act.lottery/api/v1/act/luck"
header['apitoken'] =apitoken
header['content-type'] ="application/json"
res = requests.post(url,headers=header,data=dumps(data)).json()
if res['success'] :
return(['win_prize_info']['prize_level']}-{res['data']['win_prize_info']['prize_name']}"])
else:
return(])
#去抽奖
def do_luck():
result1 = get_luck_draw_count()
if result1:
print(result1)
while True:
data = {
"code":"SCENE-202112141751413893661600711680",
"scene_code":"SCENE-202112141751413893661600711680",
"seniority_coupon":[{"sen_code":"SEN39912392052451573761600711680","sen_consume_count":1}]
}
result = luck(data)
if result:
print(f"抽奖成功:获得{result}")
else:
if '用户资格库存不足' in result:
print(f"抽奖失败:没有抽奖次数了")
elif '今日活动抽奖次数已经达到最大' == result:
print(f"抽奖失败:{result},可能需要更新抽奖码")
else:
print(f"抽奖失败:{result}")
break
sleep(float('%.1f' % uniform(2,5)))
#获取已有道具
def get_prop_count():
url = "https://gateway.jmhd8.com/geement.usercenter/api/v1/user/seniority?sencodes=SEN39912387395264184321600711680,SEN39912388659175751681600711680,SEN39912389412850237441600711680,SEN39912390071733452801600711680,SEN39912390735230402561600711680"
header['apitoken'] =apitoken
header['content-type'] ="application/x-www-form-urlencoded"
res = requests.get(url,headers=header).json()
if res['success'] :
print("您现在拥有的道具为:")
for i in res['data']:
if i['sen_code'] == "SEN39912387395264184321600711680":
prop_name = "虎头帽"
if i['sen_code'] == "SEN39912388659175751681600711680":
prop_name = "衣服"
if i['sen_code'] == "SEN39912389412850237441600711680":
prop_name = "虎头鞋"
if i['sen_code'] == "SEN39912390071733452801600711680":
prop_name = "围巾"
if i['sen_code'] == "SEN39912390735230402561600711680":
prop_name = "金虎水"
count = i['total_count']
print(f"\t{prop_name}:{count}个")
else:
print(f"获取失败:{res['msg']}")
#获取用户名
def getusername():
url = f"https://gateway.jmhd8.com/geement.usercenter/api/v1/user/information?user_id={user_id}"
res = requests.get(url).json()
if res['success'] :
if res['data']:
return res['data']['nick_name']
else:
return "未获取到用户名"
else:
return res['msg']
#获取能赠送的道具id
def get_prop_id(prop_name,gift_user_id,gift_apitoken):
if prop_name == "虎头帽":
prop_code = "SEN39912387395264184321600711680"
if prop_name == "衣服":
prop_code = "SEN39912388659175751681600711680"
if prop_name == "虎头鞋":
prop_code = "SEN39912389412850237441600711680"
if prop_name == "围巾":
prop_code = "SEN39912390071733452801600711680"
if prop_name == "金虎水":
prop_code = "SEN39912390735230402561600711680"
url = f"https://gateway.jmhd8.com/geement.usercenter/api/v1/user/seniority/details?had_expired=0&had_gift=0&had_pre_gift=0&had_used=0&sen_code={prop_code}"
header['apitoken ']= gift_apitoken #赠送人的token
res = requests.get(url,headers=header).json()
if res['success'] :
if res['data'] != []:
prop_id = []
for i in res['data']:
prop_id.append({"prop_id":i['id'],"prop_name":prop_name,"gift_user_id":gift_user_id}) #gift_user_id 赠送人的user_id
return
else:
return
else:
return ]
#转增
def give_prop(prop,gift_apitoken):
url = "https://gateway.jmhd8.com/geement.usercenter/api/v1/user/seniority/gift2"
data = {"id": prop['prop_id']}
header['apitoken ']= gift_apitoken #赠送人的token
res = requests.post(url,headers=header,data=data).json()
if res['success'] :
return f"{prop['prop_name']} {res['data']}"
else:
return res['msg']
#接收
def receive_prop(prop,receive_apitoken):
url = f"https://gateway.jmhd8.com/geement.usercenter/api/v1/user/seniority/receivegiftseniority?id={prop['prop_id']}&gift_user_id={prop['gift_user_id']}"
header['apitoken ']= receive_apitoken #接收人的token
res = requests.get(url,headers=header).json()
if res['success'] :
return f"{prop['prop_name']} {res['data']}"
else:
return res['msg']
#全部赠送 赠送人的userid 赠送人的token 接收人的token
def gift(gift_user_id,gift_apitoken,receive_apitoken):
all_prop_name = ["虎头帽","衣服","虎头鞋","围巾","金虎水"]
for prop_name in all_prop_name:
result = get_prop_id(prop_name,gift_user_id,gift_apitoken)
if result:
proplist = result
if len(proplist) != 0:
for prop in proplist:
print(give_prop(prop,gift_apitoken))
print(receive_prop(prop,receive_apitoken))
sleep(0.5)
else:
print(f"没有{prop_name}可以赠送")
else:
print(result)
sleep(0.5)
def main():
global assistance_user_id,user_id,apitoken
for user in all_user:
user_id = user['user_id']
if user_id == "":
continue
apitoken = user['apitoken']
assistance_user_id.clear()
for assistance_user in all_user:
if user_id != assistance_user['user_id'] and assistance_user['user_id'] != "":
assistance_user_id.append(assistance_user['user_id'])
if len(assistance_user_id) < 2:
assistance_user_id.append("")
assistance_user_id.append("")
print(f"\n用户:{getusername()}")
do_task() #做任务
if apitoken != "":
do_check(True) #详细检查结果有无金虎水,需apitoken
do_luck() #抽奖
get_prop_count() #获取拥有道具数量
else:
do_check(False) #粗略检查 只需user_id
#gift(all_user['user_id'],all_user['apitoken'],all_user['apitoken']) #用户2赠送全部礼物给用户1
def main_handler(event, context):
return main()
if __name__ == '__main__':
main()
获取已有道具的请求URL不是就有虎头帽 和 金虎水 的代码么。
if i['sen_code'] == "SEN39912387395264184321600711680":
prop_name = "虎头帽"
if i['sen_code'] == "SEN39912388659175751681600711680":
prop_name = "衣服"
if i['sen_code'] == "SEN39912389412850237441600711680":
prop_name = "虎头鞋"
if i['sen_code'] == "SEN39912390071733452801600711680":
prop_name = "围巾"
if i['sen_code'] == "SEN39912390735230402561600711680":
prop_name = "金虎水" {"errorCode":-1,"errorMessage":"Invoking task timed out after 3 seconds","requestId":"a864c908-ac2e-4baf-93a3-257e822caa83","statusCode":433}
测试错误 第一次用云函数这个是哪里错了 厉害了大佬 可以可以 拿去学习了 一看就是专业的{:1_918:}顺手拿来收藏研究了,方便下次抄袭{:1_907:}谢谢大佬 先收藏吧
这个很有意思,感谢大佬
这个可以,论坛有你更精彩 先复制下来,一会儿不忙时候研究一下 感谢分享~~