代码拉取完成,页面将自动刷新
package main
import (
"flag"
"github.com/go-cinch/common/log"
"go-tiktok-scrapy/workers"
"os"
"os/signal"
"syscall"
)
var workerMap map[string]func(count int) = map[string]func(count int){
"tiktok": workers.RunTikTokWorker,
"tiktok-exp": workers.RunTikTokExploreWorker,
}
func main() {
shutdown := make(chan int)
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
go func() {
<-sigChan
log.Info("Shutting down...")
shutdown <- 1
}()
var worker string
var isServer bool
var count int
flag.BoolVar(&isServer, "s", false, "Run as server")
flag.StringVar(&worker, "w", "tiktok", "Choose the worker to run")
flag.IntVar(&count, "c", 20, "Number of workers to run")
flag.Parse()
if isServer {
go Server()
} else {
f, ok := workerMap[worker]
if !ok {
panic("worker not found")
}
f(count)
}
<-shutdown
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。