[Python] 纯文本查看 复制代码
# -*- 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([True,res['data']])
else:
return([False,res['msg']])
#执行任务
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[0]
}
}, {
"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[1]
}
}, {
"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[0]:
print(f"任务成功:{result[1]}")
else:
print(f"任务失败:{result[1]}")
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 [True,True]
return [True,False]
else:
return [False,res['msg']]
#检查助力结果中有无金虎水
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 [True,True]
return [True,False]
else:
return [False,res['msg']]
#执行检查结果(choose: True 详细检查 False 粗略检查)
def do_check(choose):
if choose:
result = check2()
else:
result = check()
if result[0]:
if result[1] :
tiger = f"{getusername()}:助力结果中有金虎水,请查看"
Send(tiger)
else:
tiger = "助力结果中没有金虎水"
print(f"检查成功:{tiger}")
else:
print(f"检查失败:{result[1]}")
#获取抽奖次数
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 [True,res['msg'],res['data']]
else:
return [False,res['msg']]
#抽奖
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([True,f"{res['data']['win_prize_info']['prize_level']}-{res['data']['win_prize_info']['prize_name']}"])
else:
return([False,res['msg']])
#去抽奖
def do_luck():
result1 = get_luck_draw_count()
if result1[0]:
print(result1[1])
while True:
data = {
"code":"SCENE-202112141751413893661600711680",
"scene_code":"SCENE-202112141751413893661600711680",
"seniority_coupon":[{"sen_code":"SEN39912392052451573761600711680","sen_consume_count":1}]
}
result = luck(data)
if result[0]:
print(f"抽奖成功:获得{result[1]}")
else:
if '用户资格库存不足' in result[1]:
print(f"抽奖失败:没有抽奖次数了")
elif '今日活动抽奖次数已经达到最大' == result[1]:
print(f"抽奖失败:{result[1]},可能需要更新抽奖码")
else:
print(f"抽奖失败:{result[1]}")
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 [True,prop_id]
else:
return [False,f"未获取到可以赠送的{prop_name}"]
else:
return [False,res['msg']]
#转增
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[0]:
proplist = result[1]
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[1])
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[1]['user_id'],all_user[1]['apitoken'],all_user[0]['apitoken']) #用户2赠送全部礼物给用户1
def main_handler(event, context):
return main()
if __name__ == '__main__':
main()