用云函数实现爱奇艺自动定时签到抽奖

  • 用云函数实现爱奇艺自动定时签到抽奖已关闭评论
  • 72 views
  • A+
所属分类:其他教程

支持爱奇艺 VIP 签到、VIP 日常任务、每日三次抽奖

使用方法

腾讯云新建空白函数,语言 python3.6。复制代码进去,超时时间设置成 60 秒,设置定时触发,保存。

用云函数实现爱奇艺自动定时签到抽奖

 

酷推版本

酷推官网:https://cp.xuthus.cc/

  1. # -*- coding: utf8 -*-
  2. #爱奇艺(IQIYI)官网,加载主页面,
  3. #开发者工具搜索获取 P00001,P00003 参数
  4. #skey 为酷推 密钥,绑定发送 qq
  5. #修改 200、201、202 行代码,其中 202 行的 skey 是酷推的 skey。200 和 201 行是获取 Cookie 中的 P0001 和 P0003
  6. import time
  7. import requests
  8. class IQY:
  9.     '''
  10.     爱奇艺签到、抽奖、做日常任务(签到、任务仅限 VIP)
  11.     *奖励:签 7 天奖 1 天,14 天奖 2 天,28 天奖 7 天;日常任务;随机成长值
  12.     '''
  13.     def __init__(self, P00001, psp_uid):
  14.         '''
  15.         :param P00001: 签到,任务,抽奖必要参数
  16.         :param psp_uid: 抽奖必要参数
  17.         '''
  18.         self.P00001 = P00001
  19.         self.psp_uid = psp_uid
  20.         self.taskList = []
  21.         self.growthTask = 0
  22.     def userInformation(self):
  23.         '''
  24.         用户信息查询
  25.         '''
  26.         time.sleep(3)
  27.         url = "http://serv.vip.iqiyi.com/vipgrowth/query.action"
  28.         params = {
  29.             "P00001": self.P00001,
  30.         }
  31.         res = requests.get(url, params=params)
  32.         if res.json()["code"] == "A00000":
  33.             try:
  34.                 res_data = res.json()["data"]
  35.                 #VIP 等级
  36.                 level = res_data["level"]
  37.                 #当前 VIP 成长值
  38.                 growthvalue = res_data["growthvalue"]
  39.                 #升级需要成长值
  40.                 distance = res_data["distance"]
  41.                 #VIP 到期时间
  42.                 deadline = res_data["deadline"]
  43.                 #今日成长值
  44.                 todayGrowthValue = res_data["todayGrowthValue"]
  45.                 msg = f"VIP 等级:{level}\n 当前成长值:{growthvalue}\n 升级需成长值:{distance}\n 今日成长值:  +{todayGrowthValue}\nVIP 到期时间:{deadline}"
  46.             except:
  47.                 msg = res.json()
  48.         else:
  49.             # print("(iqy)签到错误", res.content.decode())
  50.             msg = res.json()
  51.         print(msg)
  52.         return msg
  53.     def sign(self):
  54.         '''
  55.         VIP 签到
  56.         '''
  57.         url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
  58.         params = {
  59.             "P00001": self.P00001,
  60.             "autoSign": "yes"
  61.         }
  62.         res = requests.get(url, params=params)
  63.         if res.json()["code"] == "A00000":
  64.             try:
  65.                 growth = res.json()["data"]["signInfo"]["data"]["rewardMap"]["growth"]
  66.                 continueSignDaysSum = res.json()["data"]["signInfo"]["data"]["continueSignDaysSum"]
  67.                 #vipStatus = res.json()["data"]["userInfo"]["vipStatus"]
  68.                 rewardDay = 7 if continueSignDaysSum%28<=7 else (14 if continueSignDaysSum%28<=14 else 28)
  69.                 rouund_day = 28 if continueSignDaysSum%28 == 0 else continueSignDaysSum%28
  70.                 #VIP 等级:{vipStatus}\n 签到:
  71.                 msg = f"+{growth}成长值\n 连续签到:{continueSignDaysSum}天\n 签到周期:{rouund_day}天/{rewardDay}天"
  72.             except:
  73.                 msg = res.json()["data"]["signInfo"]["msg"]
  74.         else:
  75.             # print("(iqy)签到错误", res.content.decode())
  76.             msg = res.json()["msg"]
  77.         print(msg)
  78.         return msg
  79.     def queryTask(self):
  80.         '''
  81.         获取 VIP 日常任务 和 taskCode(任务状态)
  82.         '''
  83.         url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
  84.         params = {
  85.             "P00001": self.P00001
  86.         }
  87.         res = requests.get(url, params=params)
  88.         if res.json()["code"] == "A00000":
  89.             for item in res.json()["data"]["tasks"]["daily"]:
  90.                 self.taskList.append({
  91.                     "name": item["name"],
  92.                     "taskCode": item["taskCode"],
  93.                     "status": item["status"],
  94.                     "taskReward": item["taskReward"]["task_reward_growth"]
  95.                 })
  96.         else:
  97.             # print("(iqy)获取任务失败")
  98.             pass
  99.         return self
  100.     def joinTask(self):
  101.         """
  102.         遍历完成任务
  103.         """
  104.         url = "https://tc.vip.iqiyi.com/taskCenter/task/joinTask"
  105.         params = {
  106.             "P00001": self.P00001,
  107.             "taskCode": "",
  108.             "platform": "bb136ff4276771f3",
  109.             "lang": "zh_CN"
  110.         }
  111.         # 遍历任务,仅做一次
  112.         for item in self.taskList:
  113.             if item["status"] == 2:
  114.                 params["taskCode"] = item["taskCode"]
  115.                 res = requests.get(url, params=params)
  116.                 print(res.text)
  117.     def getReward(self):
  118.         """
  119.         获取任务奖励
  120.         :return: 返回信息
  121.         """
  122.         url = "https://tc.vip.iqiyi.com/taskCenter/task/getTaskRewards"
  123.         params = {
  124.             "P00001": self.P00001,
  125.             "taskCode": "",
  126.             "platform": "bb136ff4276771f3",
  127.             "lang": "zh_CN"
  128.         }
  129.         # 遍历任务,领取奖励
  130.         for item in self.taskList:
  131.             if item["status"] == 0:
  132.                 params["taskCode"] = item["taskCode"]
  133.                 res = requests.get(url, params=params)
  134.                 if res.json()["code"] == "A00000":
  135.                     self.growthTask += item["taskReward"]
  136.         msg = f"+{self.growthTask}成长值"
  137.         print(msg)
  138.         return msg
  139.     def draw(selftype):
  140.         '''
  141.         查询抽奖次数(必),抽奖
  142.         :param type: 类型。0 查询次数;1 抽奖
  143.         :return: {status, msg, chance}
  144.         '''
  145.         url = "https://iface2.iqiyi.com/aggregate/3.0/lottery_activity"
  146.         params = {
  147.             "lottery_chance": 1,
  148.             "app_k": "b398b8ccbaeacca840073a7ee9b7e7e6",
  149.             "app_v": "11.6.5",
  150.             "platform_id": 10,
  151.             "dev_os": "8.0.0",
  152.             "dev_ua": "FRD-AL10",
  153.             "net_sts": 1,
  154.             "qyid": "2655b332a116d2247fac3dd66a5285011102",
  155.             "psp_uid": self.psp_uid,
  156.             "psp_cki": self.P00001,
  157.             "psp_status": 3,
  158.             "secure_v": 1,
  159.             "secure_p": "GPhone",
  160.             "req_sn": round(time.time()*1000)
  161.         }
  162.         # 抽奖删除 lottery_chance 参数
  163.         if type == 1:
  164.             del params["lottery_chance"]
  165.         res = requests.get(url, params=params)
  166.         # print("(iqy)抽奖信息", res.json())
  167.         if not res.json().get('code'):
  168.             chance = int(res.json().get('daysurpluschance'))
  169.             msg = res.json().get("awardName")
  170.             return {"status": True, "msg": msg, "chance": chance}
  171.         else:
  172.             try:
  173.                 msg = res.json().get("kv", {}).get("msg")
  174.             except:
  175.                 msg = res.json()["errorReason"]
  176.         print(msg)
  177.         return {"status": False, "msg": msg, "chance": 0}
  178. def sendMsg(key, content):
  179.     '''
  180.     通过酷推(https://cp.xuthus.cc/)向 QQ 发送信息
  181.     :param key: 酷推密钥
  182.     :param content: 发送内容
  183.     '''
  184.     url = f"https://push.xuthus.cc/send/{key}"
  185.     params = {
  186.         "c": content
  187.     }
  188.     res = requests.get(url, params=params)
  189. def main_handler(event, context):
  190.     P00001 = ""
  191.     P00003 = ""
  192.     skey = ""
  193.     # 签到
  194.     obj = IQY(P00001, P00003)
  195.     msg1 = obj.sign()
  196.     # 抽奖
  197.     chance = obj.draw(0)["chance"]
  198.     if chance:
  199.         msg2 = ""
  200.         for i in range(chance):
  201.             ret = obj.draw(1)
  202.             msg2 += ret["msg"]+";" if ret["status"] else ""
  203.     else:
  204.         msg2 = "抽奖机会不足"
  205.     # 日常任务
  206.     obj.queryTask().joinTask()
  207.     msg3 = obj.queryTask().getReward()
  208.     #查询用户信息
  209.     msg_user = obj.userInformation()
  210.     msg = f"【爱奇艺等级】\n{msg_user}\n-----------------------------\n【爱奇艺签到】\n 签到:{msg1}\n 任务:{msg3}\n 抽奖:{msg2}"
  211.     sendMsg(skey, msg)
  212.     return msg

server 酱版本

server 酱官网:https://sc.ftqq.com/

  1. # -*- coding: utf8 -*-
  2. #爱奇艺(IQIYI)官网,加载主页面,
  3. #开发者工具搜索获取 P00001,P00003 参数,修改 202 行和 203 行即可
  4. #skey 为 server 酱 SCKEY,修改 204 行即可
  5. import time
  6. import requests
  7. class IQY:
  8.     '''
  9.     爱奇艺签到、抽奖、做日常任务(签到、任务仅限 VIP)
  10.     *奖励:签 7 天奖 1 天,14 天奖 2 天,28 天奖 7 天;日常任务;随机成长值
  11.     '''
  12.     def __init__(self, P00001, psp_uid):
  13.         '''
  14.         :param P00001: 签到,任务,抽奖必要参数
  15.         :param psp_uid: 抽奖必要参数
  16.         '''
  17.         self.P00001 = P00001
  18.         self.psp_uid = psp_uid
  19.         self.taskList = []
  20.         self.growthTask = 0
  21.     def userInformation(self):
  22.         '''
  23.         用户信息查询
  24.         '''
  25.         time.sleep(3)
  26.         url = "http://serv.vip.iqiyi.com/vipgrowth/query.action"
  27.         params = {
  28.             "P00001": self.P00001,
  29.         }
  30.         res = requests.get(url, params=params)
  31.         if res.json()["code"] == "A00000":
  32.             try:
  33.                 res_data = res.json()["data"]
  34.                 #VIP 等级
  35.                 level = res_data["level"]
  36.                 #当前 VIP 成长值
  37.                 growthvalue = res_data["growthvalue"]
  38.                 #升级需要成长值
  39.                 distance = res_data["distance"]
  40.                 #VIP 到期时间
  41.                 deadline = res_data["deadline"]
  42.                 #今日成长值
  43.                 todayGrowthValue = res_data["todayGrowthValue"]
  44.                 msg = f"VIP 等级:{level}\n\r 当前成长值:{growthvalue}\n\r 升级需成长值:{distance}\n\r 今日成长值:  +{todayGrowthValue}\n\rVIP 到期时间:{deadline}"
  45.             except:
  46.                 msg = res.json()
  47.         else:
  48.             # print("(iqy)签到错误", res.content.decode())
  49.             msg = res.json()
  50.         print(msg)
  51.         return msg
  52.     def sign(self):
  53.         '''
  54.         VIP 签到
  55.         '''
  56.         url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
  57.         params = {
  58.             "P00001": self.P00001,
  59.             "autoSign": "yes"
  60.         }
  61.         res = requests.get(url, params=params)
  62.         if res.json()["code"] == "A00000":
  63.             try:
  64.                 growth = res.json()["data"]["signInfo"]["data"]["rewardMap"]["growth"]
  65.                 continueSignDaysSum = res.json()["data"]["signInfo"]["data"]["continueSignDaysSum"]
  66.                 #vipStatus = res.json()["data"]["userInfo"]["vipStatus"]
  67.                 rewardDay = 7 if continueSignDaysSum%28<=7 else (14 if continueSignDaysSum%28<=14 else 28)
  68.                 rouund_day = 28 if continueSignDaysSum%28 == 0 else continueSignDaysSum%28
  69.                 #VIP 等级:{vipStatus}\n 签到:
  70.                 msg = f"+{growth}成长值\n\r 连续签到:{continueSignDaysSum}天\n\r 签到周期:{rouund_day}天/{rewardDay}天"
  71.             except:
  72.                 msg = res.json()["data"]["signInfo"]["msg"]
  73.         else:
  74.             # print("(iqy)签到错误", res.content.decode())
  75.             msg = res.json()["msg"]
  76.         print(msg)
  77.         return msg
  78.     def queryTask(self):
  79.         '''
  80.         获取 VIP 日常任务 和 taskCode(任务状态)
  81.         '''
  82.         url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
  83.         params = {
  84.             "P00001": self.P00001
  85.         }
  86.         res = requests.get(url, params=params)
  87.         if res.json()["code"] == "A00000":
  88.             for item in res.json()["data"]["tasks"]["daily"]:
  89.                 self.taskList.append({
  90.                     "name": item["name"],
  91.                     "taskCode": item["taskCode"],
  92.                     "status": item["status"],
  93.                     "taskReward": item["taskReward"]["task_reward_growth"]
  94.                 })
  95.         else:
  96.             # print("(iqy)获取任务失败")
  97.             pass
  98.         return self
  99.     def joinTask(self):
  100.         """
  101.         遍历完成任务
  102.         """
  103.         url = "https://tc.vip.iqiyi.com/taskCenter/task/joinTask"
  104.         params = {
  105.             "P00001": self.P00001,
  106.             "taskCode": "",
  107.             "platform": "bb136ff4276771f3",
  108.             "lang": "zh_CN"
  109.         }
  110.         # 遍历任务,仅做一次
  111.         for item in self.taskList:
  112.             if item["status"] == 2:
  113.                 params["taskCode"] = item["taskCode"]
  114.                 res = requests.get(url, params=params)
  115.                 print(res.text)
  116.     def getReward(self):
  117.         """
  118.         获取任务奖励
  119.         :return: 返回信息
  120.         """
  121.         url = "https://tc.vip.iqiyi.com/taskCenter/task/getTaskRewards"
  122.         params = {
  123.             "P00001": self.P00001,
  124.             "taskCode": "",
  125.             "platform": "bb136ff4276771f3",
  126.             "lang": "zh_CN"
  127.         }
  128.         # 遍历任务,领取奖励
  129.         for item in self.taskList:
  130.             if item["status"] == 0:
  131.                 params["taskCode"] = item["taskCode"]
  132.                 res = requests.get(url, params=params)
  133.                 if res.json()["code"] == "A00000":
  134.                     self.growthTask += item["taskReward"]
  135.         msg = f"+{self.growthTask}成长值"
  136.         print(msg)
  137.         return msg
  138.     def draw(selftype):
  139.         '''
  140.         查询抽奖次数(必),抽奖
  141.         :param type: 类型。0 查询次数;1 抽奖
  142.         :return: {status, msg, chance}
  143.         '''
  144.         url = "https://iface2.iqiyi.com/aggregate/3.0/lottery_activity"
  145.         params = {
  146.             "lottery_chance": 1,
  147.             "app_k": "b398b8ccbaeacca840073a7ee9b7e7e6",
  148.             "app_v": "11.6.5",
  149.             "platform_id": 10,
  150.             "dev_os": "8.0.0",
  151.             "dev_ua": "FRD-AL10",
  152.             "net_sts": 1,
  153.             "qyid": "2655b332a116d2247fac3dd66a5285011102",
  154.             "psp_uid": self.psp_uid,
  155.             "psp_cki": self.P00001,
  156.             "psp_status": 3,
  157.             "secure_v": 1,
  158.             "secure_p": "GPhone",
  159.             "req_sn": round(time.time()*1000)
  160.         }
  161.         # 抽奖删除 lottery_chance 参数
  162.         if type == 1:
  163.             del params["lottery_chance"]
  164.         res = requests.get(url, params=params)
  165.         # print("(iqy)抽奖信息", res.json())
  166.         if not res.json().get('code'):
  167.             chance = int(res.json().get('daysurpluschance'))
  168.             msg = res.json().get("awardName")
  169.             return {"status": True, "msg": msg, "chance": chance}
  170.         else:
  171.             try:
  172.                 msg = res.json().get("kv", {}).get("msg")
  173.             except:
  174.                 msg = res.json()["errorReason"]
  175.         print(msg)
  176.         return {"status": False, "msg": msg, "chance": 0}
  177. def sendMsg(key, content):
  178.     '''
  179.     通过 serverkey 酱向微信发送信息
  180.     :param key:  serverkey 酱推送必要参数
  181.     :param content: 发送内容
  182.     '''
  183.     notice = requests.get(url='https://sc.ftqq.com/{}.send?text=爱奇艺执行结果&desp={}'.format(key, str(content)))
  184.     print(notice.text)
  185.     # url = f"https://sc.ftqq.com/send/{key}"
  186.     # params = {
  187.     #     "c": content
  188.     # }
  189.     # res = requests.get(url, params=params)
  190. def main_handler(event, context):
  191.     P00001 = ""
  192.     P00003 = ""
  193.     skey = ""
  194.     # 签到
  195.     obj = IQY(P00001, P00003)
  196.     msg1 = obj.sign()
  197.     # 抽奖
  198.     chance = obj.draw(0)["chance"]
  199.     if chance:
  200.         msg2 = ""
  201.         for i in range(chance):
  202.             ret = obj.draw(1)
  203.             msg2 += ret["msg"]+";" if ret["status"] else ""
  204.     else:
  205.         msg2 = "抽奖机会不足"
  206.     # 日常任务
  207.     obj.queryTask().joinTask()
  208.     msg3 = obj.queryTask().getReward()
  209.     # 查询用户信息
  210.     msg_user = obj.userInformation()
  211.     fengexian = '-' * 30
  212.     msg = f"【爱奇艺等级】\n\r{msg_user}\n\r{fengexian}\n\r【爱奇艺签到】\n\r 签到:{msg1}\n\r 抽奖:{msg2}\n\r 任务:{msg3}"
  213.     sendMsg(skey, msg)
  214.     return msg
  215. if __name__ == '__main__':
  216.     print(main_handler())
以上代码来源互联网。

 

历史上的今天: