Browse Source

redis集群新增删除方法;爬虫三级页模板新增下载附件

maxiaoshan 2 năm trước cách đây
mục cha
commit
3d6633cddd
2 tập tin đã thay đổi với 13 bổ sung1 xóa
  1. 5 0
      src/spiderutil/redisclusterutil.go
  2. 8 1
      src/spiderutil/template.go

+ 5 - 0
src/spiderutil/redisclusterutil.go

@@ -48,3 +48,8 @@ func RedisClusterExists(key string) bool {
 	}
 	return false
 }
+
+//
+func RedisClusterDelete(key string) {
+	RedisCluster.Del(ctx, key)
+}

+ 8 - 1
src/spiderutil/template.go

@@ -95,7 +95,8 @@ function downloadDetailPage(data)
 	local update="%s"
 	for i=1,3 do 	--3次下载任务不成功,退出
 		local content = download(data["href"],{})
-		 
+		
+		data["s_title"]=""
 		data["detail"]=findContentText("%s",content)
 		data["contenthtml"]=findOneHtml("%s",content)
 		data["l_np_publishtime"]=com.strToTimestamp(data["publishtime"])
@@ -103,6 +104,12 @@ function downloadDetailPage(data)
 		local checkAttr={"title","href","publishtime","detail","contenthtml"}
 		local b,err=com.checkData(checkAttr,data)
 		if b then
+			local attachments = com.getFileAttachmentsArrayWithTag(data["href"],"dl","<dl>"..data["contenthtml"].."</dl>",false)
+			if table.getn(attachments)>0 then
+				data["projectinfo"]={
+					["attachments"]=attachments
+				}
+			end
 			return data
 		else
 			timeSleep(60)--延时60秒再次请求