From 5299918ed9406525e3ca3ceb86acad1584516c6c Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Thu, 18 Aug 2022 19:07:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AD=BE=E5=88=B0=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mihoyobbs.py | 8 ++++++-- setting.py | 1 + tools.py | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mihoyobbs.py b/mihoyobbs.py index 1e98f53..37f6a12 100644 --- a/mihoyobbs.py +++ b/mihoyobbs.py @@ -1,3 +1,4 @@ +import json import time import tools import config @@ -122,8 +123,11 @@ class Mihoyobbs: log.info("讨论区任务已经完成过了~") else: log.info("正在签到......") + header = {} + header.update(self.headers) for i in setting.mihoyobbs_List_Use: - req = http.post(url=setting.bbs_Sign_url, json={"gids": i["id"]}, headers=self.headers) + header["DS"] = tools.get_ds2("", json.dumps({"gids": i["id"]})) + req = http.post(url=setting.bbs_Sign_url, json={"gids": i["id"]}, headers=header) data = req.json() if "err" not in data["message"]: log.info(str(i["name"] + data["message"])) @@ -159,7 +163,7 @@ class Mihoyobbs: if data["message"] == "OK": log.debug("点赞:{} 成功".format(self.postsList[i][1])) # 判断取消点赞是否打开 - if config.config["mihoyobbs"]["un_like"] : + if config.config["mihoyobbs"]["un_like"]: time.sleep(random.randint(2, 8)) req = http.post(url=setting.bbs_Like_url, headers=self.headers, json={"post_id": self.postsList[i][0], "is_cancel": True}) diff --git a/setting.py b/setting.py index e3ecc64..0a90146 100644 --- a/setting.py +++ b/setting.py @@ -1,5 +1,6 @@ # 米游社的Salt mihoyobbs_Salt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9" +mihoyobbs_Salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v" mihoyobbs_Salt_web = "9nQiU3AV0rJSIBWgdynfoGMGKaklfbM7" # 米游社的版本 mihoyobbs_Version = "2.34.1" # Slat和Version相互对应 diff --git a/tools.py b/tools.py index f00b61d..25dfb9e 100644 --- a/tools.py +++ b/tools.py @@ -36,6 +36,16 @@ def get_ds(web: bool) -> str: return f"{i},{r},{c}" +# 获取请求Header里的DS(版本2) 这个版本ds之前见到都是查询接口里的 +def get_ds2(q: str, b: str) -> str: + n = setting.mihoyobbs_Salt2 + i = str(timestamp()) + r = str(random.randint(100001, 200000)) + add = f'&b={b}&q={q}' + c = md5("salt=" + n + "&t=" + i + "&r=" + r + add) + return f"{i},{r},{c}" + + # 生成一个device id def get_device_id() -> str: return str(uuid.uuid3(uuid.NAMESPACE_URL, config.config["account"]["cookie"]))