From 7ef1918c87bf5ae5f0e64d8afaed105a8475d394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=90=9D?= Date: Wed, 29 Apr 2026 09:08:00 +0000 Subject: [PATCH] fix: fix crawler compilation errors --- backend/internal/crawler/ribenyan.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/internal/crawler/ribenyan.go b/backend/internal/crawler/ribenyan.go index ecff9e3..49d3e09 100644 --- a/backend/internal/crawler/ribenyan.go +++ b/backend/internal/crawler/ribenyan.go @@ -58,15 +58,10 @@ func (c *RibenyanCrawler) CrawlArticles() error { return } - // 获取链接 - link := "" + // 获取链接(暂时不使用) s.Find("a").First().Each(func(j int, ls *goquery.Selection) { - href, exists := ls.Attr("href") - if exists && !strings.HasPrefix(href, "http") { - link = "https://ribenyan.com" + href - } else if exists { - link = href - } + _, exists := ls.Attr("href") + _ = exists }) // 获取封面图 @@ -199,7 +194,8 @@ func (c *RibenyanCrawler) CrawlArticleDetail(url string) (*models.Article, error // 获取内容 var contentBuilder strings.Builder doc.Find("article, .post-content, .article-content, .entry-content").First().Each(func(i int, s *goquery.Selection) { - contentBuilder.WriteString(s.Html()) + html, _ := s.Html() + contentBuilder.WriteString(html) }) article.Content = contentBuilder.String()