This commit is contained in:
toom1996
2026-08-10 20:47:34 +08:00
parent 4c71ffde21
commit cab1023ba1
9 changed files with 621 additions and 0 deletions

44
cmd/vogue.go Normal file
View File

@ -0,0 +1,44 @@
package cmd
import (
"log"
"github.com/spf13/cobra"
"my-spiders/internal/config"
"my-spiders/internal/spider"
)
var (
brandID int64
forceUpdate bool
onlyPlatform bool
)
var vogueCmd = &cobra.Command{
Use: "vogue",
Short: "自动采集 vogue.com 网站发布会数据",
Run: func(cmd *cobra.Command, args []string) {
log.Println("[Command] 启动 Vogue 采集指令...")
// 从全局 YAML 配置中获取并发数
maxCo := config.GlobalConfig.App.MaxCo
vogueSpider := spider.NewVogueSpider(DB, maxCo)
vogueSpider.BrandID = brandID
vogueSpider.ForceUpdate = forceUpdate
vogueSpider.OnlyPlatform = onlyPlatform
vogueSpider.Debug = config.GlobalConfig.App.Debug // 赋值 Debug 状态
vogueSpider.Execute()
},
}
func init() {
rootCmd.AddCommand(vogueCmd)
vogueCmd.Flags().Int64VarP(&brandID, "brandId", "b", 0, "指定的品牌id.")
vogueCmd.Flags().BoolVarP(&forceUpdate, "forceUpdate", "f", false, "是否对已经保存的数据进行强制更新.")
vogueCmd.Flags().BoolVarP(&onlyPlatform, "onlyPlatform", "o", false, "是否只对当前平台品牌更新.")
}