1.购买服务器阿里云:服务器购买地址https://t.aliyun.com/U/Bg6shY若失效,可用地址
阿里云:
服务器购买地址
https://t.aliyun.com/U/Bg6shY若失效,可用地址
https://www.aliyun.com/daily-act/ecs/activity_selection?source=5176.29345612&userCode=49hts92d腾讯云:
https://curl.qcloud.com/wJpWmSfU若失效,可用地址
https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=ad201ee2ef3b771157f72ee5464b1fea&from=console华为云
https://activity.huaweicloud.com/cps.html?fromacct=64b5cf7cc11b4840bb4ed2ea0b2f4468&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=2019052.部署教程
3.代码如下
# cron: 15 8 * * *import requestsimport os,sys,timeimport json,refrom notify import senddef pr(message):msg.append(message + "\n")print(message)msg = []def index(safe): #登录信息try:url = f"https://wxx.ball.warhorsechina.com.cn/api/getuserinfo.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:pr(f"登陆成功,用户名:{info['nickname']}")infos(safe)print("签到")time.sleep(3)checkin(safe)print("加入排行榜")time.sleep(3)joinxcx(safe)print("点赞")time.sleep(3)subrank(safe)print("分享小程序")time.sleep(3)share(safe)time.sleep(3)print("摇一摇")sendbattle(safe)print("领马")time.sleep(3)starthorse(safe)print("登录游戏")time.sleep(3)horselogin(safe)print("抚摸小马")time.sleep(3)strokehorse(safe)print("领取签到任务")time.sleep(3)gethorsetaskcenter(safe)print("分享小游戏")time.sleep(3)sharehorse(safe)print("摇一摇信息")time.sleep(3)getbattlemsg(safe)print("偷饲料")time.sleep(3)subhorseplayer(safe)print("喂马")time.sleep(3)horseeat(safe)print("送饲料")time.sleep(3)subhorseplayer1(safe)print("查询题库")time.sleep(3)getquesbackstatus(safe)print("刷新题库")time.sleep(3)getques(safe)print("答题")time.sleep(3)getques1(safe)print("答题")time.sleep(3)getques2(safe)print("答题")time.sleep(3)getques3(safe)time.sleep(3)infos(safe)else:print("失败")except Exception as e:pr(f"执行错误: {e}")def headers():#请求头header = {"Host": "wxx.ball.warhorsechina.com.cn","Connection": "keep-alive","User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/8555","Content-Type": "application/x-www-form-urlencoded","Referer": "https://servicewechat.com/wx94dca6ef07a54c55/152/page-frame.html",}return headerdef infos(safe): #积分,能量信息url = f"https://wxx.ball.warhorsechina.com.cn/api/getusercenter.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:pr(f"积分:{info['nowscore']}")else:pr("失败")def checkin(safe): #签到url = f"https://wxx.ball.warhorsechina.com.cn/api/checkin.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print(info["msg"])else:print(info["msg"])def joinxcx(safe): #排行榜请求url = f"https://wxx.ball.warhorsechina.com.cn/api/joinxcx.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def getranklist(safe): #好友列表url = f"https://wxx.ball.warhorsechina.com.cn/api/getranklist.php?safe={safe}&type=1&fromsafe"header = headers()wx_zm_uid = []response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:listid = info['data']for rw_id in listid:wx_zm_uid.append(rw_id['id'])else:print(info)return wx_zm_uid# def getotherhorseinfo(safe): #添加好友# wx_zm_tsl = sicxs_uid()# wx_zm = []# for wx_zm_id in wx_zm_tsl:# time.sleep(5)# url = f"https://wxx.ball.warhorsechina.com.cn/api/getranklist.php?safe={safe}&type=1&fromsafe={wx_zm_id}"# header = {# "Host": "wxx.ball.warhorsechina.com.cn",# "Connection": "keep-alive",# "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/8555",# "Content-Type": "application/x-www-form-urlencoded",# "Referer": "https://servicewechat.com/wx94dca6ef07a54c55/152/page-frame.html",# }# response = requests.get(url=url,headers=header)# time.sleep(3)# response.encoding = "utf-8"# info = json.loads(response.text)# if 1 == info['status']:# wx_zm.append(wx_zm_id)# else:# print(f"添加好友{wx_zm_id} 失败: {info}")# print(f"添加{wx_zm}成功")def subrank(safe): #点赞互动wx_zm_tsl =getranklist(safe)for wx_zm_id in wx_zm_tsl:time.sleep(5)url = f"https://wxx.ball.warhorsechina.com.cn/api/subrank.php?safe={safe}&id={wx_zm_id}&type=1"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print(f"点赞{wx_zm_id}成功")else:print(f"点赞{wx_zm_id} 失败: {info['msg']}")def share(safe): #分享小程序url = f"https://wxx.ball.warhorsechina.com.cn/api/share.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def saveuserinfo(safe,wx_zm_avatar,wx_zm_nickname,wx_zm_sex,wx_zm_birthday,wx_zm_tel): #完善信息任务url = f"https://wxx.ball.warhorsechina.com.cn/api/saveuserinfo.php?safe={safe}&avatar={wx_zm_avatar}&nickname={wx_zm_nickname}&uname={wx_zm_nickname}&sex={wx_zm_sex}&birthday={wx_zm_birthday}&tel={wx_zm_tel}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print(info)else:print(info["msg"])def gzhkl(safe): #公众号口令msg = "有能量 当燃战马!"url = f"https://wxx.ball.warhorsechina.com.cn/api/gzhkl.php?safe={safe}&kl={msg}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print(info)else:print(info["msg"])def starthorse(safe): #领养马url = f"https://wxx.ball.warhorsechina.com.cn/api/starthorse.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def horselogin(safe): #登录养马url = f"https://wxx.ball.warhorsechina.com.cn/api/horselogin.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def strokehorse(safe): #抚摸马儿url = f"https://wxx.ball.warhorsechina.com.cn/api/strokehorse.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def horseeat(safe): #喂马url = f"https://wxx.ball.warhorsechina.com.cn/api/horseeat.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def subhorseplayer(safe): #偷饲料header = headers()wx_zm_tsl =getranklist(safe)for wx_zm_id in wx_zm_tsl:time.sleep(5)url = f"https://wxx.ball.warhorsechina.com.cn/api/subhorseplayer.php?safe={safe}&friendid={wx_zm_id}&type=1"response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print(f"偷饲料{wx_zm_id}成功")else:print(f"偷饲料{wx_zm_id} 失败: {info['msg']}")def subhorseplayer1(safe): #送饲料wx_zm_ssl =getranklist(safe)for wx_zm_id in wx_zm_ssl:time.sleep(5)url = f"https://wxx.ball.warhorsechina.com.cn/api/subhorseplayer.php?safe={safe}&friendid={wx_zm_id}&type=2"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print(f"送饲料{wx_zm_id}成功")else:print(f"送饲料{wx_zm_id} 失败: {info['msg']}")def gethorsetaskcenter(safe): #领取饲料任务签到url = f"https://wxx.ball.warhorsechina.com.cn/api/gethorsetaskcenter.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print(f"领取饲料:{info['checkData']['feed']},领取天数:{info['checkData']['day']}")else:print(info["msg"])def checkslgift(safe): #领互助饲料url = f"https://wxx.ball.warhorsechina.com.cn/api/checkslgift.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def sharehorse(safe): #分享公众号url = f"https://wxx.ball.warhorsechina.com.cn/api/sharehorse.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def getquesbackstatus(safe): #查询题库url = f"https://wxx.ball.warhorsechina.com.cn/api/getquesbackstatus.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("请求成功")else:print(info["msg"])def getques(safe): #刷新题库url = f"https://wxx.ball.warhorsechina.com.cn/api/getques.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:qid = info['qid']question =info['question']options =info['options']sicxs_tk_up(qid,question,options)# print(info)else:print(info["msg"])def getques1(safe): #答题1url = f"https://wxx.ball.warhorsechina.com.cn/api/subques.php?safe={safe}&qid=126&val=C"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def getques2(safe): #答题2url = f"https://wxx.ball.warhorsechina.com.cn/api/subques.php?safe={safe}&qid=138&val=C"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def getques3(safe): #答题3url = f"https://wxx.ball.warhorsechina.com.cn/api/subques.php?safe={safe}&qid=119&val=A"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def sendbattle(safe): #摇一摇url = f"https://wxx.ball.warhorsechina.com.cn/api/sendbattle.php?safe={safe}&id=2"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def getbattlemsg(safe): #摇一摇接收信息url = f"https://wxx.ball.warhorsechina.com.cn/api/getbattlemsg.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:print("成功")else:print(info["msg"])def getmyhorseinfo(safe): #获取idurl = f"https://wxx.ball.warhorsechina.com.cn/api/getmyhorseinfo.php?safe={safe}"header = headers()response = requests.get(url=url,headers=header)time.sleep(3)response.encoding = "utf-8"info = json.loads(response.text)if 1 == info['status']:return info['friendid']else:print(info["msg"])def sicxs_tk_up(qid,question,options): #上传题库response = requests.get(url=f"https://api.com/i/zm/tk/qs?qid={qid}&question={question}&options={options}")response.encoding = "utf-8"info = json.loads(response.text)def sicxs():config_path = 'config.py'if os.path.exists(config_path):import configelse:with open(config_path, 'w') as f:pr("首次运行,已创建配置文件 config.py,请按照说明填写相关变量后再次运行脚本。")f.write('#可以在此文件中添加配置变量,例如:\nsfsy = ""\n')try:env_cookie = os.environ.get("wx_zmnlxq")si_cookie = getattr(config, 'wx_zmnlxq', '')if env_cookie and si_cookie:cookies = env_cookie + "\n" + si_cookieelif env_cookie:cookies = env_cookieelif si_cookie:cookies = si_cookieelse:pr("请设置变量 export wx_zmnlxq='' 或在 config.py 中设置 wx_zmnlxq")sys.exit()except Exception as e:pr("请设置变量 export wx_zmnlxq='' 或在 config.py 中设置 wx_zmnlxq")sys.exit()list_cookie = [c for c in re.split(r'\n|&', cookies) if c.strip()]total_cookies = len(list_cookie)for i, list_cookie_i in enumerate(list_cookie):try:print(f'----------- 账号【{i + 1}/{total_cookies}】执行 -----------')pr(f"账号【{i + 1}】开始执行")index(list_cookie_i)checkslgift(list_cookie_i)except Exception as e:pr(f"账号执行出错,已跳过该账号:{e}")finally:send("战马能量星球", ''.join(msg))msg.clear()print(f'\n----------- 执 行 结 束 -----------')if __name__ == '__main__':sicxs()
该脚本为登录【战马能量星球】小程序账号,自动做每天的积分 / 能量任务,然后把执行结果通过通知推送出去。
主要方法
1. 基础工具
pr(message)同时
print到控制台,并把日志内容收集进全局msg,用于最后推送通知。headers()生成通用请求头(User-Agent、Referer 等),所有接口复用。
2. 主流程入口
sicxs()调用
index(safe)执行整套任务。调用
checkslgift(safe)领取互助饲料。调用
send("战马能量星球", ''.join(msg))推送执行结果。清空日志,处理下一个账号。
读取环境变量或
config.py里的wx_zmnlxq,支持多账号(以换行 /&/@分隔)。对每个账号的
safe参数:index(safe)infos查询积分checkin签到joinxcx加入排行榜subrank给好友点赞share分享小程序sendbattle摇一摇starthorse领养马horselogin登录小游戏strokehorse抚摸马gethorsetaskcenter领取饲料/签到任务奖励sharehorse分享相关任务getbattlemsg获取摇一摇信息subhorseplayer偷好友饲料horseeat喂马subhorseplayer1给好友送饲料getquesbackstatus查询答题状态getques刷新题库并上报到自家接口getques1/2/3提交预设题目答案再调一次
infos查看最新积分这是整个脚本的"总控"方法。
用
safe调getuserinfo.php验证登录。如果成功:
依次调用一大串任务函数(签到、互动、养马、答题等),最后再查一次信息:
3. 账户 / 积分相关
infos(safe)调
getusercenter.php。获取当前积分,打印用于展示执行结果。
4. 日常任务相关
checkin(safe)每日签到任务。
joinxcx(safe)加入小程序排行榜一类的活跃任务。
share(safe)"分享小程序"任务上报。
getranklist(safe)获取排行榜 / 好友列表,返回用户 ID,用于点赞、偷/送饲料等互动任务。
subrank(safe)遍历排行榜用户,对其进行点赞互动任务。
5. 养马玩法相关
starthorse(safe)领养小马。
horselogin(safe)登录养马小游戏。
strokehorse(safe)抚摸马,完成对应任务。
horseeat(safe)喂马,消耗饲料完成任务。
subhorseplayer(safe)从好友那偷饲料(基于
getranklist的好友 ID)。subhorseplayer1(safe)向好友送饲料,完成对应任务。
gethorsetaskcenter(safe)领取签到/任务赠送的饲料奖励。
checkslgift(safe)领取互助饲料奖励。
sharehorse(safe)分享与养马相关内容的任务。
getbattlemsg(safe)/sendbattle(safe)摇一摇相关任务:发起 & 获取结果。
6. 答题 / 题库相关
getquesbackstatus(safe)查询当前答题状态。
getques(safe)拉取当日题目(qid、题干、选项),然后调用
sicxs_tk_up上传到自有题库接口。getques1(safe)/getques2(safe)/getques3(safe)对三个固定
qid提交写死的选项,用于完成答题任务(依赖活动没变)。sicxs_tk_up(qid, question, options)将题目数据提交到
api,用于积累题库。
注意:
本文部分变量已做脱敏处理,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。技术层面需要提供帮助,可以通过打赏的方式进行探讨。
没有评论:
发表评论