Skip to content

Commit 074109f

Browse files
klxiaoniurenbaoshuoCopilot
authored
fix: parse alert message for mark query result (#49)
* fix: parse alert message for mark query result * Update mark.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: lint --------- Co-authored-by: Baoshuo <i@baoshuo.ren> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8274146 commit 074109f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mark.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package jwch
1818

1919
import (
2020
"fmt"
21+
"regexp"
2122
"strings"
2223

2324
"golang.org/x/net/html"
@@ -36,6 +37,15 @@ func (s *Student) GetMarks() (resp []*Mark, err error) {
3637
return nil, err
3738
}
3839

40+
// window.alert( '你尚有学费未缴清,暂时不能查询成绩,如有疑问请与计财处联系!');
41+
htmlStr := htmlquery.OutputHTML(res, false)
42+
re := regexp.MustCompile(`window\.alert\s*\(\s*'([^']*)'\s*\)`)
43+
matches := re.FindStringSubmatch(htmlStr)
44+
if len(matches) == 2 {
45+
message := matches[1]
46+
return nil, errno.HTMLParseError.WithMessage(message)
47+
}
48+
3949
table := htmlquery.FindOne(res, `//*[@id="ContentPlaceHolder1_DataList_xxk"]/tbody`)
4050
if table == nil {
4151
return nil, errno.HTMLParseError.WithMessage("marks table not found")

0 commit comments

Comments
 (0)