增加二次尝试登录功能 #14

This commit is contained in:
NianBroken
2024-07-15 19:56:58 +08:00 Unverified
parent e127708411
commit b691bbba34
+19
View File
@@ -87,6 +87,18 @@ class Client:
) )
doc = pq(req_login.text) doc = pq(req_login.text)
tips = doc("p#tips") tips = doc("p#tips")
if str(tips) != "":
if "用户名或密码" in tips.text():
# 使用原始密码再次尝试登录
login_data["mm"] = password
req_login = self.sess.post(
self.login_url,
headers=self.headers,
data=login_data,
timeout=self.timeout,
)
doc = pq(req_login.text)
tips = doc("p#tips")
if str(tips) != "": if str(tips) != "":
if "用户名或密码" in tips.text(): if "用户名或密码" in tips.text():
return {"code": 1002, "msg": "用户名或密码不正确"} return {"code": 1002, "msg": "用户名或密码不正确"}
@@ -97,6 +109,13 @@ class Client:
"msg": "登录成功", "msg": "登录成功",
"data": {"cookies": self.cookies}, "data": {"cookies": self.cookies},
} }
return {"code": 998, "msg": tips.text()}
self.cookies = self.sess.cookies.get_dict()
return {
"code": 1000,
"msg": "登录成功",
"data": {"cookies": self.cookies},
}
# 需要验证码,返回相关页面验证信息给用户,TODO: 增加更多验证方式 # 需要验证码,返回相关页面验证信息给用户,TODO: 增加更多验证方式
need_verify = True need_verify = True
req_kaptcha = self.sess.get(self.kaptcha_url, headers=self.headers, timeout=self.timeout) req_kaptcha = self.sess.get(self.kaptcha_url, headers=self.headers, timeout=self.timeout)