删除了ai识别验证码部分,新增个人成绩补考标识和cet成绩查询
This commit is contained in:
@@ -29,6 +29,7 @@ type GradeEntry struct {
|
||||
Score string
|
||||
GradePoint string
|
||||
IsExam string
|
||||
IsRetake bool
|
||||
}
|
||||
|
||||
type GPASummary struct {
|
||||
@@ -139,7 +140,7 @@ func parseGradesHTML(html string) ([]GradeEntry, error) {
|
||||
return
|
||||
}
|
||||
|
||||
texts := getCellTexts(cells)
|
||||
texts, isRetake := getCellTextsAndRetake(cells)
|
||||
if len(texts) < 9 {
|
||||
return
|
||||
}
|
||||
@@ -147,10 +148,11 @@ func parseGradesHTML(html string) ([]GradeEntry, error) {
|
||||
isMidterm := len(texts) == 10
|
||||
|
||||
entry := GradeEntry{
|
||||
Term: safeGet(texts, 1),
|
||||
Code: safeGet(texts, 3),
|
||||
Name: safeGet(texts, 4),
|
||||
Credit: safeGet(texts, 7),
|
||||
Term: safeGet(texts, 1),
|
||||
Code: safeGet(texts, 3),
|
||||
Name: safeGet(texts, 4),
|
||||
Credit: safeGet(texts, 7),
|
||||
IsRetake: isRetake,
|
||||
}
|
||||
|
||||
if isMidterm {
|
||||
@@ -227,7 +229,7 @@ func parseGPAHTML(html string) (*GPASummary, []GradeEntry, error) {
|
||||
return
|
||||
}
|
||||
|
||||
texts := getCellTexts(cells)
|
||||
texts, isRetake := getCellTextsAndRetake(cells)
|
||||
|
||||
entry := GradeEntry{
|
||||
Term: safeGet(texts, 0),
|
||||
@@ -239,6 +241,7 @@ func parseGPAHTML(html string) (*GPASummary, []GradeEntry, error) {
|
||||
Credit: safeGet(texts, 7),
|
||||
Score: safeGet(texts, 8),
|
||||
GradePoint: safeGet(texts, 9),
|
||||
IsRetake: isRetake,
|
||||
}
|
||||
|
||||
if entry.Name != "" && len(entry.Name) >= 2 {
|
||||
@@ -250,6 +253,32 @@ func parseGPAHTML(html string) (*GPASummary, []GradeEntry, error) {
|
||||
return summary, grades, nil
|
||||
}
|
||||
|
||||
// getCellTextsAndRetake 解析单元格文本,同时检测是否包含补考标记
|
||||
// 补考标记在HTML中表现为 <font color="#0066ff">补考</font>,
|
||||
// 解析后该单元格文本为"补考",需要从texts中移除并记录isRetake标志
|
||||
func getCellTextsAndRetake(cells *goquery.Selection) ([]string, bool) {
|
||||
var texts []string
|
||||
isRetake := false
|
||||
retakeIndex := -1
|
||||
|
||||
cells.Each(func(i int, cell *goquery.Selection) {
|
||||
text := strings.TrimSpace(cell.Text())
|
||||
// 检测补考标记:<font color="#0066ff">补考</font>
|
||||
if text == "补考" {
|
||||
isRetake = true
|
||||
retakeIndex = i
|
||||
}
|
||||
texts = append(texts, text)
|
||||
})
|
||||
|
||||
// 移除"补考"这一列,使后续列索引与正常行一致
|
||||
if isRetake && retakeIndex >= 0 {
|
||||
texts = append(texts[:retakeIndex], texts[retakeIndex+1:]...)
|
||||
}
|
||||
|
||||
return texts, isRetake
|
||||
}
|
||||
|
||||
func getCellTexts(cells *goquery.Selection) []string {
|
||||
var texts []string
|
||||
cells.Each(func(_ int, cell *goquery.Selection) {
|
||||
|
||||
Reference in New Issue
Block a user