Bläddra i källkod

更新stringFind方法,text去除空格;更新sendListNum方法

maxiaoshan 2 år sedan
förälder
incheckning
16541fb476
1 ändrade filer med 6 tillägg och 3 borttagningar
  1. 6 3
      src/spider/script.go

+ 6 - 3
src/spider/script.go

@@ -499,9 +499,10 @@ func (s *Script) LoadScript(site, channel, user *string, code, script_file strin
 	}))
 	//推送列表页下载数据量
 	s.L.SetGlobal("sendListNum", s.L.NewFunction(func(S *lua.LState) int {
+		index := S.ToInt(-2)
 		table := S.ToTable(-1)
 		list := util.TableToMap(table)
-		if len(list) > 0 {
+		if index <= 1 && len(list) > 0 {
 			UpdateHeart(*site, *channel, code, *user, "findlist") //记录列表页实际采集数据量心跳
 		}
 		return 1
@@ -918,8 +919,10 @@ func (s *Script) LoadScript(site, channel, user *string, code, script_file strin
 	s.L.SetGlobal("stringFind", s.L.NewFunction(func(S *lua.LState) int {
 		regstr := S.ToString(-1)
 		text := S.ToString(-2)
-		reg := regexp.MustCompile(regstr)
-		result := reg.FindString(text)
+		textReg := regexp.MustCompile(regstr)
+		spaceReg := regexp.MustCompile("[\\s\u3000\u2003\u00a0]+")
+		text = spaceReg.ReplaceAllString(text, "")
+		result := textReg.FindString(text)
 		isMatch := false
 		if result != "" {
 			isMatch = true