删除了ai识别验证码部分,新增个人成绩补考标识和cet成绩查询
This commit is contained in:
@@ -26,7 +26,7 @@ const (
|
||||
func createHTTPClient() (*http.Client, error) {
|
||||
jar, err := cookiejar.New(nil)
|
||||
if err != nil {
|
||||
return nil, apperr.New("create_jar", err, "创建 cookie jar 失败")
|
||||
return nil, apperr.New("create_jar", err, "鍒涘缓 cookie jar 澶辫触")
|
||||
}
|
||||
return &http.Client{Jar: jar}, nil
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func setTWFIDCookie(httpClient *http.Client, baseURL, twfid string) {
|
||||
}
|
||||
u, err := url.Parse(baseURL)
|
||||
if err != nil {
|
||||
slog.Warn("解析 baseURL 失败,无法设置 TWFID cookie", "base_url", baseURL, "error", err)
|
||||
slog.Warn("瑙f瀽 baseURL 澶辫触锛屾棤娉曡缃?TWFID cookie", "base_url", baseURL, "error", err)
|
||||
return
|
||||
}
|
||||
httpClient.Jar.SetCookies(u, []*http.Cookie{
|
||||
@@ -50,7 +50,7 @@ func executeLogin(ctx context.Context, httpClient *http.Client, username, passwo
|
||||
log := slog.With("username", username)
|
||||
|
||||
if err := client.GetInitialCookiesWithClient(httpClient); err != nil {
|
||||
return apperr.New("get_cookies", err, "获取初始 Cookie 失败")
|
||||
return apperr.New("get_cookies", err, "鑾峰彇鍒濆 Cookie 澶辫触")
|
||||
}
|
||||
|
||||
for attempt := 1; attempt <= maxLoginRetries; attempt++ {
|
||||
@@ -60,18 +60,12 @@ func executeLogin(ctx context.Context, httpClient *http.Client, username, passwo
|
||||
default:
|
||||
}
|
||||
|
||||
log.Info("尝试登录", "attempt", attempt, "max_retries", maxLoginRetries)
|
||||
|
||||
captchaCode, err := captcha.GetAndRecognize(httpClient)
|
||||
if err != nil {
|
||||
log.Warn("验证码获取失败", "error", err, "attempt", attempt)
|
||||
time.Sleep(loginRetryInterval)
|
||||
continue
|
||||
}
|
||||
log.Info("灏濊瘯鐧诲綍", "attempt", attempt, "max_retries", maxLoginRetries)
|
||||
|
||||
captchaCode := captcha.GetCaptchaCode()
|
||||
success, err := auth.LoginWithClient(httpClient, captchaCode, username, password)
|
||||
if err != nil {
|
||||
log.Warn("登录请求失败", "error", err, "attempt", attempt)
|
||||
log.Warn("鐧诲綍璇锋眰澶辫触", "error", err, "attempt", attempt)
|
||||
time.Sleep(loginRetryInterval)
|
||||
continue
|
||||
}
|
||||
@@ -80,7 +74,7 @@ func executeLogin(ctx context.Context, httpClient *http.Client, username, passwo
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Warn("登录验证失败", "attempt", attempt)
|
||||
log.Warn("鐧诲綍楠岃瘉澶辫触", "attempt", attempt)
|
||||
time.Sleep(loginRetryInterval)
|
||||
}
|
||||
|
||||
@@ -102,7 +96,7 @@ func executeLoginAndFetchSchedule(ctx context.Context, httpClient *http.Client,
|
||||
|
||||
func unmarshalPayload(payload []byte, v any) error {
|
||||
if err := json.Unmarshal(payload, v); err != nil {
|
||||
return apperr.New("parse_payload", err, "解析任务载荷失败")
|
||||
return apperr.New("parse_payload", err, "瑙f瀽浠诲姟杞借嵎澶辫触")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user