From 7b3e3ea045e861e6fbb0cc11a35c4b120013f548 Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Thu, 28 Apr 2022 14:29:18 +0800 Subject: [PATCH] =?UTF-8?q?header=E5=A4=B4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- genshin.py | 22 ++++++---------------- honkai2.py | 24 +++++++----------------- honkai3rd.py | 24 +++++++----------------- setting.py | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 50 deletions(-) diff --git a/genshin.py b/genshin.py index 697c284..981b81a 100644 --- a/genshin.py +++ b/genshin.py @@ -11,22 +11,12 @@ from account import get_account_list class Genshin: def __init__(self) -> None: - self.headers = { - 'Accept': 'application/json, text/plain, */*', - 'DS': tools.get_ds(web=True, web_old=True), - 'Origin': 'https://webstatic.mihoyo.com', - 'x-rpc-app_version': setting.mihoyobbs_Version_old, - 'User-Agent': 'Mozilla/5.0 (Linux; Android 9; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) ' - 'Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 miHoYoBBS/2.3.0', - 'x-rpc-client_type': setting.mihoyobbs_Client_type_web, - 'Referer': 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true&act_id' - f'={setting.genshin_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon', - 'Accept-Encoding': 'gzip, deflate', - 'Accept-Language': 'zh-CN,en-US;q=0.8', - 'X-Requested-With': 'com.mihoyo.hyperion', - "Cookie": config.config["account"]["cookie"], - 'x-rpc-device_id': tools.get_device_id() - } + self.headers = setting.headers + self.headers['DS'] = tools.get_ds(web=True, web_old=True) + self.headers['Referer'] = 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true'\ + f'&act_id={setting.genshin_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon' + self.headers['Cookie'] = config.config["account"]["cookie"] + self.headers['x-rpc-device_id'] = tools.get_device_id() self.acc_List = get_account_list("hk4e_cn", self.headers) if len(self.acc_List) != 0: self.sign_Give = self.get_signgive() diff --git a/honkai2.py b/honkai2.py index 3cdc372..495ddad 100644 --- a/honkai2.py +++ b/honkai2.py @@ -11,22 +11,12 @@ from account import get_account_list class Honkai2: def __init__(self) -> None: - self.headers = { - 'Accept': 'application/json, text/plain, */*', - 'DS': tools.get_ds(web=True, web_old=True), - 'Origin': 'https://webstatic.mihoyo.com', - 'x-rpc-app_version': setting.mihoyobbs_Version_old, - 'User-Agent': 'Mozilla/5.0 (Linux; Android 9; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) ' - 'Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 miHoYoBBS/2.3.0', - 'x-rpc-client_type': setting.mihoyobbs_Client_type_web, - 'Referer': 'https://webstatic.mihoyo.com/bbs/event/signin/bh2/index.html?bbs_auth_required=true&' - f'act_id={setting.honkai2_Act_id}&bbs_presentation_style=fullscreen&utm_source=bbs&' - 'utm_medium=mys&utm_campaign=icon', - 'Accept-Encoding': 'gzip, deflate', - 'Accept-Language': 'zh-CN,en-US;q=0.8', - 'X-Requested-With': 'com.mihoyo.hyperion', - "Cookie": config.config["account"]["cookie"], - 'x-rpc-device_id': tools.get_device_id() - } + self.headers = setting.headers + self.headers['DS'] = tools.get_ds(web=True, web_old=True) + self.headers['Referer'] = 'https://webstatic.mihoyo.com/bbs/event/signin/bh2/index.html?bbs_auth_required'\ + f'=true&act_id={setting.honkai2_Act_id}&bbs_presentation_style=fullscreen'\ + '&utm_source=bbs&utm_medium=mys&utm_campaign=icon' + self.headers['Cookie'] = config.config["account"]["cookie"] + self.headers['x-rpc-device_id'] = tools.get_device_id() self.acc_List = get_account_list("bh2_cn", self.headers) self.sign_day = 0 diff --git a/honkai3rd.py b/honkai3rd.py index a71cc24..5aa931b 100644 --- a/honkai3rd.py +++ b/honkai3rd.py @@ -10,23 +10,13 @@ from account import get_account_list class Honkai3rd: def __init__(self) -> None: - self.headers = { - 'Accept': 'application/json, text/plain, */*', - 'DS': tools.get_ds(web=True, web_old=True), - 'Origin': 'https://webstatic.mihoyo.com', - 'x-rpc-app_version': setting.mihoyobbs_Version_old, - 'User-Agent': 'Mozilla/5.0 (Linux; Android 9; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) ' - 'Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 miHoYoBBS/2.3.0', - 'x-rpc-client_type': setting.mihoyobbs_Client_type_web, - 'Referer': f'https://webstatic.mihoyo.com/bh3/event/euthenia/index.html?bbs_presentation_style=fullscreen' - f'&bbs_game_role_required=bh3_cn&bbs_auth_required=t' - f'rue&act_id={setting.honkai3rd_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon', - 'Accept-Encoding': 'gzip, deflate', - 'Accept-Language': 'zh-CN,en-US;q=0.8', - 'X-Requested-With': 'com.mihoyo.hyperion', - "Cookie": config.config["account"]["cookie"], - 'x-rpc-device_id': tools.get_device_id() - } + self.headers = setting.headers + self.headers['DS'] = tools.get_ds(web=True, web_old=True) + self.headers['Referer'] = 'https://webstatic.mihoyo.com/bh3/event/euthenia/index.html?bbs_presentation_style' \ + '=fullscreen&bbs_game_role_required=bh3_cn&bbs_auth_required=true&act_id=' \ + f'{setting.honkai3rd_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon' + self.headers['Cookie'] = config.config["account"]["cookie"] + self.headers['x-rpc-device_id'] = tools.get_device_id() self.acc_List = get_account_list("bh3_cn", self.headers) self.sign_day = 0 diff --git a/setting.py b/setting.py index e065b8d..e12496f 100644 --- a/setting.py +++ b/setting.py @@ -50,6 +50,23 @@ game_id2name = { # Config Load之后run里面进行列表的选择 mihoyobbs_List_Use = [] +# 游戏签到的请求头 +headers = { + 'Accept': 'application/json, text/plain, */*', + 'DS': "", + 'Origin': 'https://webstatic.mihoyo.com', + 'x-rpc-app_version': mihoyobbs_Version_old, + 'User-Agent': 'Mozilla/5.0 (Linux; Android 9; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) ' + 'Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 miHoYoBBS/2.3.0', + 'x-rpc-client_type': mihoyobbs_Client_type_web, + 'Referer': '', + 'Accept-Encoding': 'gzip, deflate', + 'Accept-Language': 'zh-CN,en-US;q=0.8', + 'X-Requested-With': 'com.mihoyo.hyperion', + "Cookie": "", + 'x-rpc-device_id': "" +} + # 通用设置 bbs_Api = "https://bbs-api.mihoyo.com" web_Api = "https://api-takumi.mihoyo.com"