update
This commit is contained in:
44
cmd/vogue.go
Normal file
44
cmd/vogue.go
Normal 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, "是否只对当前平台品牌更新.")
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user