From 632c64eba528954f06b41744489193570a494777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B4=9B?= Date: Sat, 7 Aug 2021 19:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BD=91=E6=98=93=E4=BA=91?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=92=8C=E4=BB=80=E4=B9=88=E5=80=BC=E5=BE=97?= =?UTF-8?q?=E4=B9=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ck_163game.py | 32 ++++++++++++++++++++++ ck_smzdm.py | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ config.json | 6 +++- 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 ck_163game.py create mode 100644 ck_smzdm.py diff --git a/ck_163game.py b/ck_163game.py new file mode 100644 index 0000000..3ecd1c0 --- /dev/null +++ b/ck_163game.py @@ -0,0 +1,32 @@ +import requests +import json +from getENV import getENv +from checksendNotify import send + +""" +建议cron: 20 8 * * * +new Env('网易云游戏'); +""" + +def game163(Authorization): + headers = { + 'user-agent': 'Mozilla/5.0 (Linux; Android 10; Redmi K30 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.127 Mobile Safari/537.36', + ## 下面填抓包来的参数######## + 'Authorization': Authorization + } + url = 'http://n.cg.163.com/api/v2/sign-today' + r = requests.post(url, headers=headers).text + if r[0] == "{": + return "cookie已失效" + else: + return "签到成功" + + +def start(): + getENv() + with open("/ql/config/check.json", "r", encoding="utf-8") as f: + datas = json.loads(f.read()) + _check_item = datas.get("163game", []) + res = game163(_check_item.get('Authorization')) + print(res) + send("网易云游戏", res) diff --git a/ck_smzdm.py b/ck_smzdm.py new file mode 100644 index 0000000..679bd56 --- /dev/null +++ b/ck_smzdm.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +import json +import os + +import requests +from requests import utils +from getENV import getENv +from checksendNotify import send + +""" +建议cron: 51 9 * * * +new Env('什么值得买'); +""" + +class SmzdmCheckIn: + def __init__(self, check_item): + self.check_item = check_item + + @staticmethod + def sign(session): + try: + current = session.get(url="https://zhiyou.smzdm.com/user/info/jsonp_get_current").json() + if current["checkin"]["has_checkin"]: + msg = ( + f"用户信息: {current.get('nickname', '')}\n目前积分: {current.get('point', '')}\n" + f"经验值: {current.get('exp', '')}\n金币: {current.get('gold', '')}\n" + f"碎银子: {current.get('silver', '')}\n威望: {current.get('prestige', '')}\n" + f"等级: {current.get('level', '')}\n" + f"已经签到: {current.get('checkin', {}).get('daily_checkin_num', '')} 天" + ) + else: + response = session.get(url="https://zhiyou.smzdm.com/user/checkin/jsonp_checkin").json().get("data", {}) + msg = ( + f"用户信息: {current.get('nickname', '')}\n目前积分: {response.get('point', '')}\n" + f"增加积分: {response.get('add_point', '')}\n经验值: {response.get('exp', '')}\n" + f"金币: {response.get('gold', '')}\n威望: {response.get('prestige', '')}\n" + f"等级: {response.get('rank', '')}\n" + f"已经签到: {response.get('checkin_num', {})} 天" + ) + except Exception as e: + msg = f"签到状态: 签到失败\n错误信息: {e}" + return msg + + def main(self): + smzdm_cookie = { + item.split("=")[0]: item.split("=")[1] for item in self.check_item.get("smzdm_cookie").split("; ") + } + session = requests.session() + requests.utils.add_dict_to_cookiejar(session.cookies, smzdm_cookie) + session.headers.update( + { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-CN,zh;q=0.9", + "Connection": "keep-alive", + "Host": "zhiyou.smzdm.com", + "Referer": "https://www.smzdm.com/", + "Sec-Fetch-Dest": "script", + "Sec-Fetch-Mode": "no-cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36", + } + ) + sign_msg = self.sign(session=session) + msg = f"{sign_msg}" + return msg + + +if __name__ == "__main__": + getENv() + with open("/ql/config/check.json", "r", encoding="utf-8") as f: + datas = json.loads(f.read()) + _check_item = datas.get("SMZDM_COOKIE_LIST", [])[0] + res = SmzdmCheckIn(check_item=_check_item).main() + print(res) + send('什么值得买',res) diff --git a/config.json b/config.json index 8a13e83..305875a 100644 --- a/config.json +++ b/config.json @@ -257,5 +257,9 @@ { "user": "", "password": "" - } + }, + "163game": + { + "Authorization": "" + } } \ No newline at end of file