From bbb28298f80a1e1b0575269aac3c500b274de470 Mon Sep 17 00:00:00 2001 From: milarin Date: Mon, 6 Mar 2023 11:49:13 +0100 Subject: [PATCH] getPageCount fixed --- api.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/api.go b/api.go index a313262..89158d3 100644 --- a/api.go +++ b/api.go @@ -175,9 +175,9 @@ func (api *Api) GetChapterEntriesByNovelID(novelID NovelID) *Cursor[NovelChapter func (api *Api) getPageCount(doc *goquery.Document) (int, error) { pagination := doc.Find(".digg_pagination") - if pagination.Children().Length() >= 6 { - // more than 4 pages (next_page + last_page + collapsed_pages buttons included) - pageCount, err := strconv.ParseInt(pagination.Find("a:nth-child(5)").Text(), 10, 64) + if pagination.Length() > 0 { + // more than 1 page + pageCount, err := strconv.ParseInt(pagination.Find("a:nth-last-child(2)").Text(), 10, 64) if err != nil { adverr.Println(ErrApiElementNotFound.Wrap(err, ".digg_pagination a:nth-child(5)")) return 0, err @@ -185,13 +185,7 @@ func (api *Api) getPageCount(doc *goquery.Document) (int, error) { return int(pageCount), nil } else { - pageCount, err := strconv.ParseInt(pagination.Find(".next_page").Text(), 10, 64) - if err != nil { - adverr.Println(ErrApiElementNotFound.Wrap(err, ".digg_pagination a:nth-child(5)")) - return 0, err - } - - return int(pageCount), nil + return 1, nil } }