diff --git a/ForumHelper.py b/ForumHelper.py index 18550d81b..cec68662d 100644 --- a/ForumHelper.py +++ b/ForumHelper.py @@ -11,7 +11,6 @@ print(f"登录名: {name}") print(f"密码: {password}") - # tr.monika.love # 创建会话 session = rq.Session() @@ -43,11 +42,13 @@ # 修复插件列表路径 md = re.sub(r'\b[^(\[]*\/README.md\b', lambda x: "https://gitee.com/kksjsj/TShockPlugin/blob/master/" + x.group(), md) -# 编辑论坛仓库帖子 data = { "text": md } html = rq.post("https://api.github.com/markdown", headers=headers, data=json.dumps(data)).text + + +# 编辑论坛仓库帖子 data = { "_xfToken": data_csrf, "prefix_id[]": 7, @@ -99,23 +100,8 @@ } session.post("https://trhub.cn/login/login",data=data,allow_redirects=True) -# 使用GithubAPI转换MD到Html -with open('README.md', 'r',encoding='utf-8') as file: - md = file.read() -headers = { - "Accept": "application/vnd.github+json", - #"Authorization": "Bearer ", - "X-GitHub-Api-Version": "2022-11-28" -} - -# 修复插件列表路径 -md = re.sub(r'\b[^(\[]*\/README.md\b', lambda x: "https://gitee.com/kksjsj/TShockPlugin/blob/master/" + x.group(), md) # 编辑论坛仓库帖子 -data = { - "text": md -} -html = rq.post("https://api.github.com/markdown", headers=headers, data=json.dumps(data)).text data = { "_xfToken": data_csrf, "prefix_id": 0, @@ -147,7 +133,7 @@ name = "Cai233" # 创建会话 session = rq.Session() -resp = session.get("https://tr.lizigo.cn/") +resp = session.get("https://www.bbstr.net/") # 获取xf_token soup = BeautifulSoup(resp.text, 'html.parser') @@ -160,28 +146,12 @@ "login":name, "password": password, "remember": 0, - "_xfRedirect": "https://tr.lizigo.cn/", -} -session.post("https://tr.lizigo.cn/login/login",data=data,allow_redirects=True) - - -# 使用GithubAPI转换MD到Html -with open('README.md', 'r',encoding='utf-8') as file: - md = file.read() -headers = { - "Accept": "application/vnd.github+json", - #"Authorization": "Bearer ", - "X-GitHub-Api-Version": "2022-11-28" + "_xfRedirect": "https://www.bbstr.net/", } +session.post("https://www.bbstr.net/login/login",data=data,allow_redirects=True) -# 修复插件列表路径 -md = re.sub(r'\b[^(\[]*\/README.md\b', lambda x: "https://gitee.com/kksjsj/TShockPlugin/blob/master/" + x.group(), md) # 编辑论坛仓库帖子 -data = { - "text": md -} -html = rq.post("https://api.github.com/markdown", headers=headers, data=json.dumps(data)).text data = { "title": "TShock插件收集仓库(自动更新版)", "tag_line": "此帖会自动更新插件列表(BBSTR高概率同步失败)", @@ -216,7 +186,7 @@ try: - resp = session.post("https://tr.lizigo.cn/resources/167/edit",data=data) + resp = session.post("https://www.bbstr.net/resources/167/edit",data=data,timeout=10) res = resp.json() if res['status'] == 'ok': print(f"[BBSTR]修改成功: {res}") diff --git a/ForumUpdate.py b/ForumUpdate.py index 2911f52b3..d3a75ec4f 100644 --- a/ForumUpdate.py +++ b/ForumUpdate.py @@ -13,7 +13,7 @@ -html =f'✅ [{result[0]["title"]}]({result[0]["html_url"]}) ({datetime.datetime.strptime(result[0]["closed_at"], "%Y-%m-%dT%H:%M:%SZ").date()})' +html = f'{result[0]["title"]} ({datetime.datetime.strptime(result[0]["closed_at"], "%Y-%m-%dT%H:%M:%SZ").date()})' # 读取用户名 密码 name = sys.argv[1] password = sys.argv[2] @@ -114,7 +114,7 @@ name = "Cai233" # 创建会话 session = rq.Session() -resp = session.get("https://tr.lizigo.cn/") +resp = session.get("https://www.bbstr.net/",timeout=10) # 获取xf_token soup = BeautifulSoup(resp.text, 'html.parser') @@ -127,9 +127,9 @@ "login":name, "password": password, "remember": 0, - "_xfRedirect": "https://tr.lizigo.cn/", + "_xfRedirect": "https://www.bbstr.net/", } -session.post("https://tr.lizigo.cn/login/login",data=data,allow_redirects=True) +session.post("https://www.bbstr.net/login/login",data=data,allow_redirects=True) # 模拟登录 @@ -150,7 +150,7 @@ "_xfResponseType": "json" } try: - resp = session.post("https://tr.lizigo.cn/threads/2427/add-reply",data=data) + resp = session.post("https://www.bbstr.net/threads/2427/add-reply",data=data,timeout=10) res = resp.json() if res['status'] == 'ok': print(f"[BBSTR]修改成功: {res}")