浏览代码

正文提取发布时间工具类

maxiaoshan 4 年之前
父节点
当前提交
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
+	}))
 }
 
 //