package main import ( "intimate" "log" "github.com/474420502/hunter" "github.com/tidwall/gjson" ) var targetTypeUser = "openrec_user" var targetTypeRanking = "openrec_ranking" var oer *OpenrecExtratorRanking // store 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql var store *intimate.Store = intimate.NewStore("source_openrec") func init() { oer = &OpenrecExtratorRanking{} } // OpenrecExtratorRanking 获取用户信息 type OpenrecExtratorRanking struct { // Store *intimate.Store } // Execute 执行方法 func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) { source, err := store.Pop(targetTypeRanking) if err != nil { log.Println(err) return } if source != nil { result := gjson.Parse(source.GetSource().String) if result.IsArray() { for _, User := range result.Array() { userid := User.Get("channel.id").String() openrecUser := &OpenrecUser{} openrecUser.PreGetUrl = hunter.PreGetUrl("https://www.openrec.tv/user/" + userid + "/supporters") cxt.AddParentTask(openrecUser) } } else { log.Println("array error:", result.Str) } } } // OpenrecUser 获取用户信息 type OpenrecUser struct { hunter.PreGetUrl } // Execute 执行方法 func (oer *OpenrecUser) Execute(cxt *hunter.TaskContext) { }