Эх сурвалжийг харах

正文提取发布时间工具类

maxiaoshan 4 жил өмнө
parent
commit
6094521291
1 өөрчлөгдсөн 8 нэмэгдсэн , 0 устгасан
  1. 8 0
      src/spider/script.go

+ 8 - 0
src/spider/script.go

@@ -433,6 +433,14 @@ func (s *Script) LoadScript(downloadnode, script string, isfile ...string) {
 		S.Push(lua.LString(result))
 		return 1
 	}))
+	//根据正文获取发布时间
+	s.L.SetGlobal("getPublishtime", s.L.NewFunction(func(S *lua.LState) int {
+		detail := S.ToString(-2)
+		contenthtml := S.ToString(-1)
+		publishtime := util.GetPublishtime([]string{contenthtml, detail})
+		S.Push(lua.LString(publishtime))
+		return 1
+	}))
 }
 
 //