From f6a492d7983d202bce290b976ad9bb66b21c955b Mon Sep 17 00:00:00 2001 From: Nicr0n <845182672@qq.com> Date: Wed, 10 Jul 2024 02:58:53 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9headers=E4=B8=ADcookie?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D=20=E4=BF=AE=E6=94=B9=E5=9F=9F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/SCF_sign.py | 22 +++++++++++++--------- dist/SCF_work.py | 17 ++++++++--------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/dist/SCF_sign.py b/dist/SCF_sign.py index 16a8909..6108480 100644 --- a/dist/SCF_sign.py +++ b/dist/SCF_sign.py @@ -12,11 +12,11 @@ # ======== CONSTANT ======== -sign_url = 'https://www.tsdm39.net/plugin.php?id=dsu_paulsign:sign' -work_url = 'https://www.tsdm39.net/plugin.php?id=np_cliworkdz:work' -login_url = 'https://www.tsdm39.net/member.php?mod=logging&action=login' +sign_url = 'https://www.tsdm39.com/plugin.php?id=dsu_paulsign:sign' +work_url = 'https://www.tsdm39.com/plugin.php?id=np_cliworkdz:work' +login_url = 'https://www.tsdm39.com/member.php?mod=logging&action=login' -tsdm_domain = ".tsdm39.net" +tsdm_domain = ".tsdm39.com" s1_domain = "bbs.saraba1st.com" @@ -39,7 +39,7 @@ def get_cookies_all(): def get_cookies_by_domain(domain:str): """从所有cookie里分离出指定域名的cookie - domain: cookie_list domain, (".tsdm39.net") + domain: cookie_list domain, (".tsdm39.com") """ cookies_all = get_cookies_all() # { username: [cookie_list] } domain_cookies = {} @@ -62,7 +62,7 @@ def get_cookies_by_domain(domain:str): # ======= SIGN ====== sign_page_with_param = \ - 'https://www.tsdm39.net/plugin.php?id=dsu_paulsign:sign&operation=qiandao&infloat=1&sign_as=1&inajax=1' + 'https://www.tsdm39.com/plugin.php?id=dsu_paulsign:sign&operation=qiandao&infloat=1&sign_as=1&inajax=1' def sign_single_post_v2(cookie): @@ -72,9 +72,9 @@ def sign_single_post_v2(cookie): headers = { 'accept': 'text/html, application/xhtml+xml, image/jxr, */*', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko', - 'cookie_list': cookie_serialized, + 'cookie': cookie_serialized, 'connection': 'Keep-Alive', - 'referer': 'https://www.tsdm39.net/home.php?mod=space&do=pm', + 'referer': 'https://www.tsdm39.com/home.php?mod=space&do=pm', 'content-type': 'application/x-www-form-urlencoded' } @@ -88,6 +88,7 @@ def sign_single_post_v2(cookie): sign_response = s.post(sign_page_with_param, data=sign_data, headers=headers) + if "恭喜你签到成功!获得随机奖励" in sign_response.text: print("签到成功") return True @@ -97,7 +98,9 @@ def sign_single_post_v2(cookie): print("签到失败: 目前不在签到时间段") elif "未定义操作" in sign_response.text: print("%s签到失败, 可能是formhash获取错误" % datetime.now()) - print("签到", sign_response.text) + # print("签到", sign_response.text) + elif "您需要先登录才能继续本操作" in sign_response.text: + print("header设置错误") else: print("%s======未知原因签到失败, 已保存response=======" % datetime.now()) print("签到", sign_response.text) @@ -106,6 +109,7 @@ def sign_single_post_v2(cookie): def sign_multi_post(): + print("loading cookies") cookies = get_cookies_by_domain(tsdm_domain) for user in cookies.keys(): diff --git a/dist/SCF_work.py b/dist/SCF_work.py index b967a5d..ccf646f 100644 --- a/dist/SCF_work.py +++ b/dist/SCF_work.py @@ -12,11 +12,11 @@ from typing import List # ======== CONSTANT ======== -sign_url = 'https://www.tsdm39.net/plugin.php?id=dsu_paulsign:sign' -work_url = 'https://www.tsdm39.net/plugin.php?id=np_cliworkdz:work' -login_url = 'https://www.tsdm39.net/member.php?mod=logging&action=login' +sign_url = 'https://www.tsdm39.com/plugin.php?id=dsu_paulsign:sign' +work_url = 'https://www.tsdm39.com/plugin.php?id=np_cliworkdz:work' +login_url = 'https://www.tsdm39.com/member.php?mod=logging&action=login' -tsdm_domain = ".tsdm39.net" +tsdm_domain = ".tsdm39.com" s1_domain = "bbs.saraba1st.com" @@ -38,7 +38,7 @@ def get_cookies_all(): def get_cookies_by_domain(domain: str): """从所有cookie里分离出指定域名的cookie - domain: cookie_list domain, (".tsdm39.net") + domain: cookie_list domain, (".tsdm39.com") """ cookies_all = get_cookies_all() # { username: [cookie_list] } domain_cookies = {} @@ -69,10 +69,10 @@ def work_single_post(cookie: List): # 必须要这个content-type, 否则没法接收 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko', - 'cookie_list': cookie_serialized, + 'cookie': cookie_serialized, 'connection': 'Keep-Alive', 'x-requested-with': 'XMLHttpRequest', - 'referer': 'https://www.tsdm39.net/plugin.php?id=np_cliworkdz:work', + 'referer': 'https://www.tsdm39.com/plugin.php?id=np_cliworkdz:work', 'content-type': 'application/x-www-form-urlencoded' } @@ -131,6 +131,5 @@ def work_multi_post(): print("POST方式: 全部打工完成") return - def main_handler(event, context): - work_multi_post() + work_multi_post() \ No newline at end of file