feat: add carousel support and ribenyan crawler
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"sale/internal/crawler"
|
||||
"sale/internal/models"
|
||||
"sale/internal/schemas"
|
||||
"sale/internal/utils"
|
||||
@@ -162,3 +163,15 @@ func (h *ArticleHandler) TogglePin(c *gin.Context) {
|
||||
utils.DB.Model(&article).Update("is_pinned", !article.IsPinned)
|
||||
c.JSON(http.StatusOK, gin.H{"data": article})
|
||||
}
|
||||
|
||||
// CrawlRibenyan 采集 ribenyan.com 文章
|
||||
func (h *ArticleHandler) CrawlRibenyan(c *gin.Context) {
|
||||
crawler := crawler.NewRibenyanCrawler(utils.DB)
|
||||
|
||||
if err := crawler.CrawlArticles(); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Crawl completed successfully"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user