From 9681462dcc15b7392794c49dd1060dc3a2e17a77 Mon Sep 17 00:00:00 2001 From: SchwarzSail <1424928981@qq.com> Date: Tue, 7 Jan 2025 01:49:43 +0800 Subject: [PATCH] fix getting the first page error --- notice.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/notice.go b/notice.go index 44215b9..7b4b09e 100644 --- a/notice.go +++ b/notice.go @@ -27,11 +27,21 @@ import ( ) func (s *Student) GetNoticeInfo(req *NoticeInfoReq) (list []*NoticeInfo, err error) { + // 获取通知公告页面的总页数 res, err := s.PostWithIdentifier(constants.NoticeInfoQueryURL, map[string]string{}) if err != nil { return nil, err } + // 首页直接爬取 + if req.PageNum == 1 { + list, err = parseNoticeInfo(res) + if err != nil { + return nil, err + } + return list, nil + } + // 分页需要根据页数计算 url lastPageNum, err := getTotalPages(res) if err != nil { return nil, err @@ -82,6 +92,7 @@ func parseNoticeInfo(doc *html.Node) ([]*NoticeInfo, error) { URL: url, Date: date, } + fmt.Println(title) list = append(list, noticeInfo) }