Explorar o código

spider_downloadrage记录最后一次采集到数据的心跳时间

maxiaoshan %!s(int64=2) %!d(string=hai) anos
pai
achega
997099d4ef
Modificáronse 2 ficheiros con 4 adicións e 1 borrados
  1. 1 1
      src/spider/script.go
  2. 3 0
      src/spider/spider.go

+ 1 - 1
src/spider/script.go

@@ -60,7 +60,7 @@ type Script struct {
 	MaxPage             int          //采集最大页
 	PageOneTextHash     string       //爬虫第一页页面内容hash
 	PageTwoTextHash     string       //爬虫第二页页面内容hash
-	RecordedHeartInfo   bool         //是否已记录心跳信息(避免记录频率过快)
+	RecordedHeartInfo   bool         //每轮次列表页是否已采集到数据标记(避免记录频率过快)
 }
 
 const (

+ 3 - 0
src/spider/spider.go

@@ -472,6 +472,9 @@ func (s *Spider) DownListPageItem() (errs interface{}) {
 		} else {
 			inc["zero"] = 1
 		}
+		if s.RecordedHeartInfo {
+			set["lastgetdatatime"] = time.Now().Unix() //记录最新轮次采集到数据的时间
+		}
 		query := map[string]interface{}{
 			"date":       sDate,
 			"spidercode": s.Code,