bbs&原神验证码支持
This commit is contained in:
parent
1e6b05b16c
commit
96425586e8
9
captcha.py
Normal file
9
captcha.py
Normal file
@ -0,0 +1,9 @@
|
||||
from request import http
|
||||
|
||||
|
||||
def game_captcha(gt: str, challenge: str):
|
||||
return None # 失败返回None 成功返回validate
|
||||
|
||||
|
||||
def bbs_captcha(gt: str, challenge: str):
|
||||
return None
|
10
genshin.py
10
genshin.py
@ -2,6 +2,7 @@ import time
|
||||
import tools
|
||||
import config
|
||||
import random
|
||||
import captcha
|
||||
import setting
|
||||
from error import *
|
||||
from request import http
|
||||
@ -46,10 +47,12 @@ class Genshin:
|
||||
return data["data"]
|
||||
|
||||
def check_in(self, account):
|
||||
header = {}
|
||||
header.update(self.headers)
|
||||
for i in range(4):
|
||||
if i != 0:
|
||||
log.info(f'触发验证码,即将进行第{i}次重试,最多3次')
|
||||
req = http.post(url=setting.genshin_Signurl, headers=self.headers,
|
||||
req = http.post(url=setting.genshin_Signurl, headers=header,
|
||||
json={'act_id': setting.genshin_Act_id, 'region': account[2], 'uid': account[1]})
|
||||
if req.status_code == 429:
|
||||
time.sleep(10) # 429同ip请求次数过多,尝试sleep10s进行解决
|
||||
@ -57,6 +60,11 @@ class Genshin:
|
||||
continue
|
||||
data = req.json()
|
||||
if data["retcode"] == 0 and data["data"]["success"] == 1:
|
||||
validate = captcha.game_captcha()
|
||||
if validate is not None:
|
||||
header["x-rpc-challenge"] = data["data"]["challenge"]
|
||||
header["x-rpc-validate"] = validate
|
||||
header["x-rpc-seccode"] = f'{validate}|jordan'
|
||||
time.sleep(random.randint(6, 15))
|
||||
else:
|
||||
break
|
||||
|
30
mihoyobbs.py
30
mihoyobbs.py
@ -3,6 +3,7 @@ import time
|
||||
import tools
|
||||
import config
|
||||
import random
|
||||
import captcha
|
||||
import setting
|
||||
from request import http
|
||||
from loghelper import log
|
||||
@ -47,6 +48,22 @@ class Mihoyobbs:
|
||||
def refresh_list(self) -> None:
|
||||
self.postsList = self.get_list()
|
||||
|
||||
def get_pass_challenge(self):
|
||||
req = http.get(url=setting.bbs_get_captcha, headers=self.headers)
|
||||
data = req.json()
|
||||
if data["retcode"] != 0:
|
||||
return None
|
||||
validate = captcha.bbs_captcha(data["data"]["gt"], data["data"]["challenge"])
|
||||
if validate is not None:
|
||||
check_req = http.post(url=setting.bbs_captcha_verify, headers=self.headers,
|
||||
json={"geetest_challenge": data["data"]["challenge"],
|
||||
"geetest_seccode": validate+"|jordan",
|
||||
"geetest_validate": validate})
|
||||
check = check_req.json()
|
||||
if check["retcode"] == 0:
|
||||
return check["data"]["challenge"]
|
||||
return None
|
||||
|
||||
# 获取任务列表,用来判断做了哪些任务
|
||||
def get_tasks_list(self):
|
||||
global today_get_coins
|
||||
@ -152,16 +169,27 @@ class Mihoyobbs:
|
||||
|
||||
# 点赞
|
||||
def like_posts(self):
|
||||
header = {}
|
||||
header.update(self.headers)
|
||||
challenge = None
|
||||
if self.Task_do["bbs_Like_posts"]:
|
||||
log.info("点赞任务已经完成过了~")
|
||||
else:
|
||||
log.info("正在点赞......")
|
||||
for i in range(self.Task_do["bbs_Like_posts_num"]):
|
||||
req = http.post(url=setting.bbs_Like_url, headers=self.headers,
|
||||
req = http.post(url=setting.bbs_Like_url, headers=header,
|
||||
json={"post_id": self.postsList[i][0], "is_cancel": False})
|
||||
data = req.json()
|
||||
if data["message"] == "OK":
|
||||
log.debug("点赞:{} 成功".format(self.postsList[i][1]))
|
||||
if challenge is not None:
|
||||
challenge = None
|
||||
header.pop("x-rpc-challenge")
|
||||
elif data["retcode"] == 1034:
|
||||
log.warning("点赞触发验证码")
|
||||
challenge = self.get_pass_challenge()
|
||||
if challenge is not None:
|
||||
header["x-rpc-challenge"] = challenge
|
||||
# 判断取消点赞是否打开
|
||||
if config.config["mihoyobbs"]["cancel_like_posts"]:
|
||||
time.sleep(random.randint(2, 8))
|
||||
|
Loading…
Reference in New Issue
Block a user