From 950c57c88a5b54421ba4a1980fd9d4ebdc8e0015 Mon Sep 17 00:00:00 2001 From: SchwarzSail <1424928981@qq.com> Date: Sat, 11 Jan 2025 20:18:37 +0800 Subject: [PATCH] fix according copilot --- jwch_test.go | 5 ++++- notice.go | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jwch_test.go b/jwch_test.go index f794c8e..08068e1 100644 --- a/jwch_test.go +++ b/jwch_test.go @@ -279,10 +279,13 @@ func TestGetExamRoomInfo(t *testing.T) { } func TestGetNoticesInfo(t *testing.T) { - _, err := stu.GetNoticeInfo(&NoticeInfoReq{PageNum: 2}) + content, err := stu.GetNoticeInfo(&NoticeInfoReq{PageNum: 2}) if err != nil { t.Error(err) } + if content == nil { + t.Error("content is nil") + } } func TestGetCultivatePlan(t *testing.T) { diff --git a/notice.go b/notice.go index d561cb8..0bf0e80 100644 --- a/notice.go +++ b/notice.go @@ -79,6 +79,9 @@ func parseNoticeInfo(doc *html.Node) ([]*NoticeInfo, error) { for _, row := range rows { // 提取日期 dateNode := htmlquery.FindOne(row, ".//span[@class='doclist_time']") + if dateNode == nil { + return nil, fmt.Errorf("cannot find the date") + } date := strings.TrimSpace(htmlquery.InnerText(dateNode)) // 提取标题