Files
spider/cmd/vogue.go
toom1996 d8f667e391 update
2026-09-13 00:52:09 +08:00

39 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cmd
import (
"github.com/spf13/cobra"
"my-spiders/internal/spider"
)
var (
brandID int64
maxCo int
maxShows int
)
var vogueCmd = &cobra.Command{
Use: "vogue",
Short: "启动 Vogue 时装发布会采集器",
Run: func(cmd *cobra.Command, args []string) {
// 1. 修复参数数量 & 类型强转 uint(brandID)
vogueSpider := spider.NewVogueSpider(maxCo, uint(brandID), maxShows, IngestClient)
// 2. 修复方法名:将 Execute() 改为 Run()
vogueSpider.Run()
},
}
func init() {
rootCmd.AddCommand(vogueCmd)
// 绑定命令行参数
vogueCmd.Flags().Int64VarP(&brandID, "brand", "b", 0, "指定抓取的品牌 ID")
// 修复:将 "c" 改为 "m"(或者 ""),避免与全局的 -c 参数冲突
vogueCmd.Flags().IntVarP(&maxCo, "max-co", "m", 5, "最大并发数限制")
// 小批量试爬:仅抓取单个品牌的前 N 场发布会(0=不限制)。用于控制入库量 / 先看效果。
vogueCmd.Flags().IntVarP(&maxShows, "max-shows", "s", 0, "单个品牌最多抓取的发布会场次(0=不限制,小批量试爬用)")
}