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()