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: 11 11 * * *"""import requestsimport osimport reimport time# 推送开关,True为开启,False为关闭sendnotify = Truesend_msg = ''one_msg = ''def Log(cont=''):global send_msg, one_msgif cont:one_msg += f'\n{cont}'send_msg += f'\n{cont}'def send_notification_message(title):try:from notify import sendprint("加载通知服务成功!")send(title, send_msg)except Exception as e:if e:print('发送通知消息失败!')api_headers = {'Host': 'api.zhumanito.cn','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) UnifiedPCWindowsWechat(0xf2541022) XWEB/16571','authorization': '','accept': '*/*','origin': 'https://h5.zhumanito.cn','sec-fetch-site': 'same-site','sec-fetch-mode': 'cors','sec-fetch-dest': 'empty','referer': 'https://h5.zhumanito.cn/','accept-language': 'zh-CN,zh;q=0.9','priority': 'u=1, i',}def login(wid):headers = {'Host': 'api.zhumanito.cn','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) UnifiedPCWindowsWechat(0xf2541022) XWEB/16571','content-type': 'application/json;charset=UTF-8','accept': '*/*','origin': 'https://h5.zhumanito.cn','sec-fetch-site': 'same-site','sec-fetch-mode': 'cors','sec-fetch-dest': 'empty','referer': 'https://h5.zhumanito.cn/','accept-language': 'zh-CN,zh;q=0.9','priority': 'u=1, i',}try:response = requests.post('https://api.zhumanito.cn/api/login', headers=headers, json={'wid': wid})response.raise_for_status()response_json = response.json()if response_json['code'] == 200 and response_json['msg'] == '成功':print(f"登录成功,用户ID: {wid},拥有番茄:{response_json['data']['user']['fruit_num']} 个")Log(f"登录成功,用户ID: {wid},拥有番茄:{response_json['data']['user']['fruit_num']} 个")if '"seed_stage":0' in response.text:print(f"未种植番茄")Log(f"未种植番茄")time.sleep(1)seed_tomato(response_json['data']['token'])return response_json['data']['token']else:print(f"用户ID: {wid} 登录失败: {response_json['msg']}")Log(f"用户ID: {wid} 登录失败: {response_json['msg']}")return Noneexcept requests.RequestException as e:print(f"获取用户数据网络请求失败: {e}")except ValueError as e:print(f"获取用户数据解析JSON响应失败: {e}")except KeyError as e:print(f"获取用户数据JSON响应中缺少键: {e}")except Exception as e:print(f"获取用户数据时发生未知错误: {e}")def get_tomato(user_token):headers = api_headers.copy()headers['authorization'] = user_tokentry:response = requests.post('https://api.zhumanito.cn/api/harvest', headers=headers)response.raise_for_status()response_json = response.json()if response_json['code'] == 200 and response_json['msg'] == '成功':print(f"番茄收获成功,获得番茄:{response_json['data']['fruit_up']} 个")Log(f"番茄收获成功,获得番茄:{response_json['data']['fruit_up']} 个")seed_tomato(user_token)else:print(f"收获番茄失败: {response_json['msg']}")Log(f"收获番茄失败: {response_json['msg']}")except requests.RequestException as e:print(f"收获番茄网络请求失败: {e}")except ValueError as e:print(f"收获番茄解析JSON响应失败: {e}")except KeyError as e:print(f"收获番茄JSON响应中缺少键: {e}")except Exception as e:print(f"收获番茄时发生未知错误: {e}")def seed_tomato(user_token):headers = api_headers.copy()headers['authorization'] = user_tokentry:response = requests.post('https://api.zhumanito.cn/api/seed', headers=headers)response.raise_for_status()response_json = response.json()if response_json['code'] == 200 and response_json['msg'] == '成功':print(f"番茄种植成功")Log(f"番茄种植成功")else:print(f"番茄种植失败: {response_json['msg']}")Log(f"番茄种植失败: {response_json['msg']}")except requests.RequestException as e:print(f"番茄种植网络请求失败: {e}")except ValueError as e:print(f"番茄种植解析JSON响应失败: {e}")except KeyError as e:print(f"番茄种植JSON响应中缺少键: {e}")except Exception as e:print(f"番茄种植时发生未知错误: {e}")def get_task(user_token):headers = api_headers.copy()headers['authorization'] = user_tokentry:response = requests.get('https://api.zhumanito.cn/api/task?', headers=headers)response.raise_for_status()response_json = response.json()if response_json['code'] == 200 and response_json['msg'] == '成功':print(f"获取任务成功")task_lists = []for task_list in response_json['data']['task']:task_name = task_list['content']reward_water = task_list['water_num']reward_sun = task_list['sun_num']if task_list['status'] == 1:print(f"任务: {task_name}, 奖励水: {reward_water}, 奖励阳光: {reward_sun} 已完成")else:print(f"任务: {task_name}, 奖励水: {reward_water}, 奖励阳光: {reward_sun} 未完成")task_lists.append({'task_id': task_list['id'],'task_name': task_name,})return task_listselse:print(f"获取任务失败: {response_json['msg']}")return Noneexcept requests.RequestException as e:print(f"获取任务数据网络请求失败: {e}")except ValueError as e:print(f"获取任务数据解析JSON响应失败: {e}")except KeyError as e:print(f"获取任务数据JSON响应中缺少键: {e}")except Exception as e:print(f"获取任务数据时发生未知错误: {e}")def get_task_again(user_token):headers = api_headers.copy()headers['authorization'] = user_tokentry:response = requests.get('https://api.zhumanito.cn/api/task?', headers=headers)response.raise_for_status()response_json = response.json()if response_json['code'] == 200 and response_json['msg'] == '成功':print(f"获取任务成功")for task_list in response_json['data']['task']:task_name = task_list['content']reward_water = task_list['water_num']reward_sun = task_list['sun_num']if task_list['status'] == 1:print(f"任务: {task_name}, 奖励水: {reward_water}, 奖励阳光: {reward_sun} 已完成")Log(f"任务: {task_name}, 奖励水: {reward_water}, 奖励阳光: {reward_sun} 已完成")else:print(f"任务: {task_name}, 奖励水: {reward_water}, 奖励阳光: {reward_sun} 未完成")Log(f"任务: {task_name}, 奖励水: {reward_water}, 奖励阳光: {reward_sun} 未完成")else:print(f"获取任务失败: {response_json['msg']}")Log(f"获取任务失败: {response_json['msg']}")return Noneexcept requests.RequestException as e:print(f"获取任务数据网络请求失败: {e}")except ValueError as e:print(f"获取任务数据解析JSON响应失败: {e}")except KeyError as e:print(f"获取任务数据JSON响应中缺少键: {e}")except Exception as e:print(f"获取任务数据时发生未知错误: {e}")def task_complete(user_token, task_id,task_name):headers = api_headers.copy()headers['authorization'] = user_tokenheaders['content-type'] = 'application/x-www-form-urlencoded;charset=UTF-8'try:response = requests.post('https://api.zhumanito.cn/api/task/complete', headers=headers, data=f'task_id={task_id}&')response.raise_for_status()response_json = response.json()if response_json['code'] == 200 and response_json['msg'] == '成功':for task_status in response_json['data']['task']:if task_status['task_id'] == task_id and task_status['status']:print(f"任务: {task_name} 成功,剩余水: {response_json['data']['user']['water_num']}, 剩余阳光: {response_json['data']['user']['sun_num']}")else:print(f"任务: {task_name} 失败: {response_json['msg']}")except requests.RequestException as e:print(f"完成任务: {task_name} 时网络请求失败: {e}")except ValueError as e:print(f"完成任务: {task_name} 时解析JSON响应失败: {e}")except KeyError as e:print(f"完成任务: {task_name} 时JSON响应中缺少键: {e}")except Exception as e:print(f"完成任务: {task_name} 时发生未知错误: {e}")def water(user_token):headers = api_headers.copy()headers['authorization'] = user_tokenheaders['content-type'] = 'application/x-www-form-urlencoded;charset=UTF-8'try:response = requests.post('https://api.zhumanito.cn/api/water', headers=headers)response.raise_for_status()response_json = response.json()if response_json['code'] == 200 and response_json['msg'] == '成功':print(f"浇水成功,剩余水: {response_json['data']['user']['water_num']}, 剩余阳光: {response_json['data']['user']['sun_num']}")Log(f"浇水成功,剩余水: {response_json['data']['user']['water_num']}, 剩余阳光: {response_json['data']['user']['sun_num']}")return Trueelif response_json['code'] == 10006 and response_json['msg'] == '能量值不足了,可以坚持做任务获取哦~':print("不够水了")Log("不够水了")return Falseelif response_json['code'] == 10007 and response_json['msg'] == '今日浇水已达到上限,请明天再来哦~':print("今日浇水次数已达到上限")Log("今日浇水次数已达到上限")return Falseelif response_json['code'] == 10008 and response_json['msg'] == '已成熟,不必浇灌':print("番茄已成熟,自动收获")Log("番茄已成熟,自动收获")get_tomato(user_token)return Trueelse:print(f"浇水失败: {response_json['msg']}")return Falseexcept requests.RequestException as e:print(f"浇水时网络请求失败: {e}")except ValueError as e:print(f"浇水时解析JSON响应失败: {e}")except KeyError as e:print(f"浇水时JSON响应中缺少键: {e}")except Exception as e:print(f"浇水时发生未知错误: {e}")def view_page(wid):headers = {'Host': 'api.zhumanito.cn','accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','sec-fetch-site': 'same-site','sec-fetch-dest': 'document','accept-language': 'zh-CN,zh-Hans;q=0.9','sec-fetch-mode': 'navigate','user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.64(0x1800402b) NetType/WIFI Language/zh_CN miniProgram/wx532ecb3bdaaf92f9','referer': 'https://h5.zhumanito.cn/',}requests.get(f'https://api.zhumanito.cn/?wid={wid}', headers=headers)if __name__ == '__main__':if 'tyqh' in os.environ:tyqh_session = re.split("@|&", os.environ.get("tyqh"))print(f'查找到{len(tyqh_session)}个账号')else:tyqh_session = []if tyqh_session:z = 1for wid in tyqh_session:print('*'*50)print(f'开始处理第{z}个账号')Log(f'处理第{z}个账号:')print('-' * 30)token = login(wid)print('-' * 30)all_task = get_task(token)print('-'*30)print('开始做任务')for task in all_task:if task['task_name'] == '浏览指定页面':view_page(wid)print('任务: 浏览指定页面 成功')continuetask_complete(token, task['task_id'], task['task_name'])time.sleep(1)print('-' * 30)while water(token):time.sleep(1)passget_task_again(token)Log('\n')z += 1time.sleep(2)else:print('请填入tyqh变量')Log('请填入tyqh变量')if sendnotify:try:send_notification_message(title='统一茄皇') # 发送通知except Exception as e:print('推送失败:' + str(e))
该脚本用于 统一茄皇小程序自动化养番茄,通过抓包获取 wid 登录账号后,完成以下自动操作:
多账号自动登录(支持
@或&分隔)自动执行每日任务(含浏览页面任务)
自动循环浇水(直到水不足、次数上限或番茄成熟)
番茄成熟后自动收获并重新种植
记录执行日志并发送通知
适合在青龙面板等定时平台定时运行。
主要方法
| Log(cont) | |
| send_notification_message(title) | notify 模块推送脚本执行结果。 |
| login(wid) | wid 登录账号,返回用户 token,并检测是否需要自动种植番茄。 |
| get_tomato(token) | |
| seed_tomato(token) | |
| get_task(token) | task_id 和名称。 |
| get_task_again(token) | |
| task_complete(token, task_id, task_name) | |
| water(token) | |
| view_page(wid) |
注意:
本文部分变量已做脱敏处理,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。技术层面需要提供帮助,可以通过打赏的方式进行探讨。
没有评论:
发表评论