Skip to content

Commit

Permalink
fix: undefined error
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuxia211 committed Dec 7, 2024
1 parent e9d8e91 commit f3cc358
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions jwch.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ func (s *Student) NewRequest() *resty.Request {
func (s *Student) GetWithIdentifier(url string) (*html.Node, error) {
resp, err := s.NewRequest().SetHeader("Referer", constants.JwchReferer).SetQueryParam("id", s.Identifier).Get(url)
if err != nil {
return nil, errno.IdentifierExpiredError.WithErr(err)
return nil, errno.CookieExpiredError.WithErr(err)
}

// 会话过期 TODO: 判断条件有点简陋
if strings.Contains(string(resp.Body()), "重新登录") {
return nil, errno.IdentifierExpiredError
return nil, errno.CookieExpiredError
}

return htmlquery.Parse(bytes.NewReader(resp.Body()))
Expand All @@ -97,12 +97,12 @@ func (s *Student) PostWithIdentifier(url string, formData map[string]string) (*h
s.NewRequest().EnableTrace()

if err != nil {
return nil, errno.IdentifierExpiredError.WithErr(err)
return nil, errno.CookieExpiredError.WithErr(err)
}

// Identifier缺失 TODO: 判断条件有点简陋
if strings.Contains(string(resp.Body()), "处理URL失败") {
return nil, errno.IdentifierExpiredError
return nil, errno.CookieExpiredError
}

return htmlquery.Parse(strings.NewReader(strings.TrimSpace(string(resp.Body()))))
Expand Down
2 changes: 1 addition & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (s *Student) CheckSession() error {
res := htmlquery.FindOne(resp, `//*[@id="ContentPlaceHolder1_LB_xh"]`)

if res == nil {
return errno.IdentifierExpiredError.WithErr(err)
return errno.CookieExpiredError.WithErr(err)
}

if htmlquery.OutputHTML(res, false) != s.ID {
Expand Down

0 comments on commit f3cc358

Please sign in to comment.