Browse Source

新增des加解密方法

maxiaoshan 2 years ago
parent
commit
09303c97d0
2 changed files with 11 additions and 2 deletions
  1. 9 0
      src/spider/script.go
  2. 2 2
      src/spider/spider.go

+ 9 - 0
src/spider/script.go

@@ -750,6 +750,15 @@ func (s *Script) LoadScript(site *string, code, script_file string, newstate boo
 		S.Push(lua.LString(result))
 		return 1
 	}))
+	//des ecb模式解密
+	s.L.SetGlobal("desDecryptECB", s.L.NewFunction(func(S *lua.LState) int {
+		origData := S.ToString(-2)
+		key := S.ToString(-1)
+		b, _ := base64.StdEncoding.DecodeString(origData)
+		result := util.DesECBDecrypter(b, []byte(key))
+		S.Push(lua.LString(result))
+		return 1
+	}))
 	//根据正文获取发布时间
 	s.L.SetGlobal("getPublishtime", s.L.NewFunction(func(S *lua.LState) int {
 		detail := S.ToString(-2)

+ 2 - 2
src/spider/spider.go

@@ -97,7 +97,7 @@ func GetListDataDownloadDetail() {
 func DownloadHighDetail(code string) {
 	defer qu.Catch()
 	for {
-		//logger.Info("爬虫代码:", s.Code, "已下架:", s.Stop)
+		logger.Info("爬虫代码:", code, "开始下载...")
 		//if !s.Stop { //爬虫是运行状态
 		/*
 			1、每轮开始先查询当天下载的数据
@@ -134,7 +134,7 @@ func DownloadHighDetail(code string) {
 			//}
 			q["comeintime"] = comeintime
 			list, _ = MgoS.Find("spider_highlistdata", q, o, f, false, 0, 100)
-			//logger.Debug("code:", code, "query:", q, "当前查询数据量:", len(*list))
+			logger.Info("code:", code, "query:", q, "当前查询数据量:", len(*list))
 			if list != nil && len(*list) > 0 {
 				break
 			} else {