From d14644238f56afbb26b435d7fbce299a94cf979b Mon Sep 17 00:00:00 2001 From: Admin Date: Wed, 4 Mar 2026 16:54:00 +0500 Subject: [PATCH] fix(scraper): fix ScrapeCatalogue selectors, zero-byte cache skip, and wire ScrapeRanking into runAsync - ScrapeCatalogue: use li.novel-item (was div), extract href from outer and title from h4.novel-title (was h3), detect next page via rel=next (was class=next) - handleBrowse/triggerBrowseSnapshot: treat zero-byte MinIO cache entries as misses, skip storing empty SingleFile output - runAsync: after a successful full-catalogue run, call ScrapeRanking and upsert each result into PocketBase ranking collection --- scraper/internal/novelfire/scraper.go | 45 ++++++++++++++++++++------- scraper/internal/server/server.go | 37 +++++++++++++++++++++- 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/scraper/internal/novelfire/scraper.go b/scraper/internal/novelfire/scraper.go index 10b55f1..720752d 100644 --- a/scraper/internal/novelfire/scraper.go +++ b/scraper/internal/novelfire/scraper.go @@ -142,24 +142,28 @@ func (s *Scraper) ScrapeCatalogue(ctx context.Context) (<-chan scraper.Catalogue return } - // Extract novel cards:
- cards := htmlutil.FindAll(root, scraper.Selector{Tag: "div", Class: "novel-item", Multiple: true}) + // Extract novel cards:
  • + // + //
    + //

    Title

    + //
    + cards := htmlutil.FindAll(root, scraper.Selector{Tag: "li", Class: "novel-item", Multiple: true}) if len(cards) == 0 { s.log.Warn("no novel cards found, stopping pagination", "page", page) return } for _, card := range cards { - // Title:

    Title - titleNode := htmlutil.FindFirst(card, scraper.Selector{Tag: "h3", Class: "novel-title"}) + // The outer carries the href;

    has the title text. + linkNode := htmlutil.FindFirst(card, scraper.Selector{Tag: "a", Attr: "href"}) + titleNode := htmlutil.FindFirst(card, scraper.Selector{Tag: "h4", Class: "novel-title"}) var title, href string + if linkNode != nil { + href = htmlutil.ExtractText(linkNode, scraper.Selector{Tag: "a", Attr: "href"}) + } if titleNode != nil { - linkNode := htmlutil.FindFirst(titleNode, scraper.Selector{Tag: "a", Attr: "href"}) - if linkNode != nil { - title = htmlutil.ExtractText(linkNode, scraper.Selector{}) - href = htmlutil.ExtractText(linkNode, scraper.Selector{Tag: "a", Attr: "href"}) - } + title = strings.TrimSpace(htmlutil.ExtractText(titleNode, scraper.Selector{})) } if href == "" || title == "" { continue @@ -173,8 +177,27 @@ func (s *Scraper) ScrapeCatalogue(ctx context.Context) (<-chan scraper.Catalogue } } - // Find next page link: