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)) // 提取标题