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 } }