Przeglądaj źródła

新版爬虫异常信息统计定时任务

maxiaoshan 2 lat temu
rodzic
commit
b8ffd23749
4 zmienionych plików z 14 dodań i 0 usunięć
  1. 1 0
      src/config.json
  2. 1 0
      src/main.go
  3. 10 0
      src/timetask/random.go
  4. 2 0
      src/util/config.go

+ 1 - 0
src/config.json

@@ -136,6 +136,7 @@
 	"luamovecron": "0 0 8 1 * *",
 	"updateluausercron": "0 30 23 ? * *",
 	"updatesitecron": "0 30 9 ? * *",
+	"newstartaskcron": "0 0 7 ? * *",
 	"closenum": 2,
 	"daynum": 6,
 	"mail": {

+ 1 - 0
src/main.go

@@ -54,6 +54,7 @@ func main() {
 	//爬虫任务
 	c.AddFunc(util.ResetDataStateCron, luatask.ResetDataState) //重置数据
 	c.AddFunc(util.StartTaskCron, luatask.StartTask)           //爬虫维护任务
+	c.AddFunc(util.NewStarTaskCron, luatask.NewStartTask)      //新版爬虫维护任务
 	//爬虫相关周报统计
 	c.AddFunc(util.SpiderWeeklyReportCron, timetask.SpiderWeeklyReport)
 	//lua小组周报

+ 10 - 0
src/timetask/random.go

@@ -21,6 +21,8 @@ type WarnInfo struct {
 	Code     interface{}
 	Href     interface{}
 	Repeat   bool
+	Entry    bool
+	//Infotype int
 }
 
 var ErrorStypeMap = map[string]int{
@@ -28,6 +30,7 @@ var ErrorStypeMap = map[string]int{
 	"Field Value Contains Random Code": 2,
 	"Field Value Not Contains Chinese": 2,
 	"Detail File Err":                  2,
+	"Field Type Error":                 2,
 }
 var WarnStypeMap = map[string]int{
 	"Attachment Upload Failed": 1,
@@ -94,6 +97,7 @@ func GetHighlistDetailFilErrData() {
 			result["href"] = tmp["href"]
 			result["spidercode"] = tmp["spidercode"]
 			result["comeintime"] = time.Now().Unix()
+			result["entry"] = false
 			//publishtime
 			publishtime_str := qu.ObjToString(tmp["publishtime"])
 			publishtime_int := int64(0)
@@ -183,8 +187,12 @@ func GetSpiderWarnData() {
 			}()
 			info := qu.ObjToString(tmp["info"])
 			level := qu.IntAll(tmp["level"])
+			entry, _ := tmp["entry"].(bool)
 			//指定的错误类型和级别匹配的数据,推送spider_warn_err
 			if ErrorStypeMap[info] == level || WarnStypeMap[info] == level {
+				if info == "Field Value Is Null" && entry { //字段为空,但是会入bidding库的数据不推送
+					return
+				}
 				publishtime := int64(0)
 				data, ok := tmp["data"].(map[string]interface{})
 				if ok {
@@ -222,6 +230,7 @@ func GetSpiderWarnData() {
 						Code:     tmp["code"],
 						Href:     href,
 						Repeat:   repeat,
+						Entry:    entry,
 					}
 					result[href] = warnInfo
 				} else {
@@ -272,6 +281,7 @@ func GetSpiderWarnData() {
 				"data":       w.Data,
 				"ok":         false,
 				"from":       "warn",
+				"entry":      w.Entry,
 			})
 			if len(saveArr) > 500 {
 				util.MgoS.SaveBulk("spider_warn_err", saveArr...)

+ 2 - 0
src/util/config.go

@@ -32,6 +32,7 @@ var (
 	LuamoveCron                string        //每月1日统计要转移节点的爬虫
 	UpdateLuaUserCron          string        //每天更新外包爬虫到内部人员
 	UpdateSiteCron             string        //每天更新站点信息
+	NewStarTaskCron            string        //新版爬虫维护任务
 	CloseNum                   int           //关闭几天的任务
 	DayNum                     int           //更新数据天数
 	CodeEventModel             map[int]int   //节点对应的采集模式0:老模式;1:新模式
@@ -103,6 +104,7 @@ func InitOther() {
 	LuamoveCron = qu.ObjToString(Config["luamovecron"])
 	UpdateLuaUserCron = qu.ObjToString(Config["updateluausercron"])
 	UpdateSiteCron = qu.ObjToString(Config["updatesitecron"])
+	NewStarTaskCron = qu.ObjToString(Config["newstartaskcron"])
 
 	CloseNum = qu.IntAll(Config["closenum"])
 	DayNum = qu.IntAll(Config["daynum"])