maxiaoshan 3 лет назад
Родитель
Сommit
f86eae8ae6
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      src/spider/spider.go

+ 16 - 0
src/spider/spider.go

@@ -817,6 +817,14 @@ func (s *Spider) DownloadHighDetail() {
 					_id := tmp["_id"]
 					query := map[string]interface{}{"_id": _id}
 					href := qu.ObjToString(tmp["href"])
+					//由于目前列表页redis判重是href+code可能导致同一条href有多条不同code采集的数据存在
+					//为了避免重复下载,进行增量redis判重
+					isExist, _ := util.ExistRedis("title_repeat_judgement", 0, "url_repeat_"+href)
+					if isExist {
+						set := map[string]interface{}{"$set": map[string]interface{}{"state": 1, "exist": true}} //已存在state置为1
+						Mgo.Update("spider_highlistdata", query, set, false, false)
+						continue
+					}
 					if isEsRepeat { //es数据title判重
 						title := qu.ObjToString(tmp["title"])
 						eTime := time.Now().Unix()
@@ -953,6 +961,14 @@ func (s *Spider) DownloadListDetail() {
 			_id := tmp["_id"]
 			query := map[string]interface{}{"_id": _id}
 			href := qu.ObjToString(tmp["href"])
+			//由于目前列表页redis判重是href+code可能导致同一条href有多条不同code采集的数据存在
+			//为了避免重复下载,进行增量redis判重
+			isExist, _ := util.ExistRedis("title_repeat_judgement", 0, "url_repeat_"+href)
+			if isExist {
+				set := map[string]interface{}{"$set": map[string]interface{}{"state": 1, "exist": true}} //已存在state置为1
+				Mgo.Update("spider_highlistdata", query, set, false, false)
+				continue
+			}
 			if isEsRepeat { //es数据title判重
 				title := qu.ObjToString(tmp["title"])
 				eTime := time.Now().Unix()