1.购买服务器
阿里云:
服务器购买地址
https://t.aliyun.com/U/nxyLKd若失效,可用地址
https://www.aliyun.com/activity/wuying/dj?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.代码如下
import requestsimport jsonimport osfrom urllib.parse import quoteimport time as timemodulefrom datetime import datetime, timedelta, timeaccounts = os.getenv('pgsh')accounts_list = os.environ.get('pgsh').split('@')num_of_accounts = len(accounts_list)print(f"获取到 {num_of_accounts} 个账号,""仅供学习")for i, account in enumerate(accounts_list, start=1):values = account.split('#')token, name = values[0], values[1]print(f"\n=======执行账号{name}=======")url = "https://userapi.qiekj.com/task/completed"headers = {"Host": "userapi.qiekj.com","Authorization": token,"Version": "1.39.0","channel": "android_app","content-length": "60","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Connection": "Keep-Alive","Accept-Encoding": "gzip","User-Agent": "okhttp/3.14.9",}print(f"--💖APP视频💖--")for j in range(11):data = f"taskType=2&token={token}"response = requests.post(url, headers=headers, data=data).json()timemodule.sleep(5)if response['data'] == True:print(f"已完成{j + 1}次")else:print("APP广告任务完成")breakprint(f"--🍈ZFB视频🍈--")for t in range(11):data = f"taskType=9&token={token}"response = requests.post(url, headers=headers, data=data).json()timemodule.sleep(5)if response['data'] == True:print(f"已完成{t + 1}次")else:print("支付宝广告任务完成")breakprint(f"--🍥看广告赚积分🍥--")for m in range(8):data = f"taskCode=18893134-715b-4307-af1c-b5737c70f58d&token={token}"response = requests.post(url, headers=headers, data=data).json()timemodule.sleep(3)if response['data'] == True:print(f"已完成{m + 1}次")else:print("任务完成")breakprint(f"--🥝浏览商品🥝--")url = "https://qemyapi.qiekj.com/api/search_item_list"headers = {"Host": "qemyapi.qiekj.com","Authorization": token,"Version": "1.38.0","channel": "android_app","content-length": "60","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Accept-Encoding": "gzip","User-Agent": "okhttp/3.14.9",}data2 = f"keyWord=%E9%98%B2%E6%99%92%E8%A1%A3&page=1&pageSize=20&token={token}"response = requests.post(url, headers=headers, data=data2).json()task_ids = [taskItem['item_id'] for taskItem in response['data']['data'][:6]]for task_id in task_ids:url = "https://userapi.qiekj.com/integralUmp/rewardIntegral"headers = {"Host": "userapi.qiekj.com","Authorization": token,"Version": "1.38.0","channel": "android_app","content-length": "60","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Accept-Encoding": "gzip","User-Agent": "okhttp/3.14.9",}data3 = f"itemCode={task_id}&token={token}"response = requests.post(url, headers=headers, data=data3).json()if response['data'] is None:print("浏览完成")breakelse:score = response['data']['rewardIntegral']print(f"获得积分:{score}")timemodule.sleep(5)print(f"--👻报名积分打卡👻--")current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")encoded_current_time = quote(current_time)headers = {"Host": "userapi.qiekj.com","Authorization": token,"Version": "1.38.0","channel": "android_app","content-length": "60","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Connection": "Keep-Alive","Accept-Encoding": "gzip","User-Agent": "okhttp/3.14.9",}url1 = "https://userapi.qiekj.com/markActivity/queryMarkTaskByStartTime"url2 = "https://userapi.qiekj.com/markActivity/doApplyTask"data4 = {'startTime': encoded_current_time, 'token': token}respones = requests.post(url1, headers=headers, data=data4).json()["data"]["taskCode"]data5 = {"taskCode": respones, "token": token, }respone = requests.post(url2, headers=headers, data=data5).json()["msg"]print(f'积分报名结果:{respone}')timemodule.sleep(2)print(f"--🐼签到🐼--")url = "https://userapi.qiekj.com/signin/signInAcList"data6 = {"token": token}response = requests.post(url, headers=headers, data=data6).json()["data"]["id"]url1 = "https://userapi.qiekj.com/signin/doUserSignIn"data7 = {"activityId": response, "token": token}qiandao = requests.post(url1, headers=headers, data=data7).json()if qiandao["msg"] == '成功':print("签到成功获得:", qiandao["data"]["totalIntegral"])else:print(qiandao["msg"])timemodule.sleep(2)print(f"--💮瓜分积分💮--")url1 = "https://userapi.qiekj.com/markActivity/queryMarkTaskByStartTime"url2 = "https://userapi.qiekj.com/markActivity/doMarkTask"url3 = "https://userapi.qiekj.com/markActivity/markTaskReward"current_datetime = datetime.now()yesterday_datetime = current_datetime - timedelta(days=1)yesterday_now = yesterday_datetime.replace(hour=current_datetime.hour, minute=current_datetime.minute, second=current_datetime.second)k = quote(yesterday_now.strftime("%Y-%m-%d %H:%M:%S"))data = {"startTime": k, "token": token}respones = requests.post(url1, headers=headers, data=data).json()["data"]["taskCode"]data1 = {"taskCode": respones, "token": token,}respone = requests.post(url2, headers=headers, data=data1).json()["msg"]current_time = datetime.now().time()afternoon_two = time(14, 10, 0)if current_time > afternoon_two:guafen = requests.post(url3, headers=headers, data=data1).json()["data"]print("获得:", guafen)else:print("当前未到瓜分时间")timemodule.sleep(2)print(f"--🌸查询积分🌸--")url = "https://userapi.qiekj.com/signin/getTotalIntegral"headers = {"Host": "userapi.qiekj.com","Authorization": token,"Version": "1.38.0","channel": "android_app","content-length": "60","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Accept-Encoding": "gzip","User-Agent": "okhttp/3.14.9",}data8 = f"token={token}"response = requests.post(url, headers=headers, data=data8)data = response.json()['data']if data is not None:print(f'账户剩余积分:{data}')
解析
这是为了处理胖乖生活APP中的多个账号,实现自动化的日常任务,如签到、视频观看、广告浏览、商品浏览和积分打卡等。
主要功能
环境变量读取:
从环境变量
pgsh中读取账号信息,该信息包含了多个账号的认证token和名称,账号间用@分隔,每个账号内部的token与名称用#分隔。任务自动化执行:
对每个账号执行系列预设任务,包括观看APP内视频、支付宝视频、广告,以及浏览商品等。
使用
requests.post方法向特定的API发送请求,执行任务并获得响应数据。根据任务类型和响应内容判断任务是否完成,以及记录和打印获得的积分或结果。
任务详细执行流程:
观看视频:根据设定的任务类型(如APP视频或支付宝视频),循环观看并检查完成状态。
浏览商品并获得积分:请求特定商品信息,对每个商品执行浏览操作并获得积分。
积分打卡和签到:报名参与积分打卡活动,执行签到,检查并打印签到结果。
瓜分积分:根据当前时间判断是否到达瓜分积分的时间,如果到达,则执行瓜分积分操作。
反馈和日志:
为每个账号打印执行过程中的详细日志,包括任务的执行状态和获得的积分。
对错误和特殊情况进行处理,确保程序的健壮性。
安全和认证:
通过设置合适的
headers(如Authorization、User-Agent等)确保请求被服务器正确接收和处理。
通过这个脚本,可以大大减少日常在胖乖生活APP中的手动操作,实现自动化管理多个账号的日常任务,提高效率。
注意:
本文部分变量已做脱敏处理,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。技术层面需要提供帮助,可以通过打赏的方式进行探讨。
没有评论:
发表评论