Files
spider/cmd/vogue.go
toom1996 3afd10e049 update
2026-08-11 00:49:59 +08:00

36 lines
935 B
Go

package cmd
import (
"github.com/spf13/cobra"
"my-spiders/internal/spider"
)
var (
brandID int64
onlyPlatform bool
maxCo int
)
var vogueCmd = &cobra.Command{
Use: "vogue",
Short: "启动 Vogue 时装发布会采集器",
Run: func(cmd *cobra.Command, args []string) {
// 1. 修复参数数量 & 类型强转 uint(brandID)
vogueSpider := spider.NewVogueSpider(DB, maxCo, uint(brandID), onlyPlatform)
// 2. 修复方法名:将 Execute() 改为 Run()
vogueSpider.Run()
},
}
func init() {
rootCmd.AddCommand(vogueCmd)
// 绑定命令行参数
vogueCmd.Flags().Int64VarP(&brandID, "brand", "b", 0, "指定抓取的品牌 ID")
vogueCmd.Flags().BoolVarP(&onlyPlatform, "only-platform", "p", false, "是否仅抓取平台关联品牌")
// 修复:将 "c" 改为 "m"(或者 ""),避免与全局的 -c 参数冲突
vogueCmd.Flags().IntVarP(&maxCo, "max-co", "m", 5, "最大并发数限制")
}