瀏覽代碼

gorunjs server config

maxiaoshan 2 年之前
父節點
當前提交
efcbd49d6d
共有 3 個文件被更改,包括 14 次插入2 次删除
  1. 2 1
      src/config.json
  2. 9 0
      src/spider/script.go
  3. 3 1
      src/util/config.go

+ 2 - 1
src/config.json

@@ -56,9 +56,10 @@
   "msgname": "爬虫采集平台7100",
   "msgserveraddr": "spdata.jianyu360.com:801",
   "msgserveraddrfile": "spdata.jianyu360.com:802",
-  "serveraddress": "127.0.0.1:8030",
   "tesseractadd": "http://test.qmx.top:1688",
   "testdir": "res/test/spider_test.lua",
+  "serveraddress": "127.0.0.1:8030",
+  "jsserveraddress":  "127.0.0.1:8031",
   "word":{
     "keyword":"(抽签|中标|招标|成交|合同|中标候选人|资格预审|拟建|邀请|询价|比选|议价|竞价|磋商|采购|招投标|答疑|变更公告|更正公告|竞争性谈判|竞谈|意见征询|澄清|单一来源|流标|废标|验收公告|中止|终止|违规|处罚|征集公告|开标结果|评审结果|监理|招租|租赁|评判结果|项目|遴选|补遗|竞标|征求意见)",
     "notkeyword":"(招聘|拍卖|出租|出让|使用权|资产)"

+ 9 - 0
src/spider/script.go

@@ -8,6 +8,7 @@ import (
 	"encoding/base64"
 	"encoding/json"
 	"github.com/shopspring/decimal"
+	gojs "gorunjs/client"
 	"io/ioutil"
 	mu "mfw/util"
 	"net/http"
@@ -876,6 +877,14 @@ func (s *Script) LoadScript(site, channel, user *string, code, script_file strin
 		S.Push(lua.LString(respCookie))
 		return 3
 	}))
+	s.L.SetGlobal("goRunJs", s.L.NewFunction(func(S *lua.LState) int {
+		param := S.ToString(-2) //list or detail
+		step := S.ToString(-1)  //参数
+		result := gojs.GoRunJsGetResult(s.SCode, param, step)
+		qu.Debug("Go Run Js Result:", param, step, result)
+		S.Push(lua.LString(result))
+		return 1
+	}))
 	s.L.SetGlobal("newDownloadFile", s.L.NewFunction(func(S *lua.LState) int {
 		cookie := S.ToString(-1)
 		head := S.ToTable(-2)

+ 3 - 1
src/util/config.go

@@ -2,6 +2,7 @@ package util
 
 import (
 	codegrpc "analysiscode/client"
+	gojs "gorunjs/client"
 	"mongodb"
 	qu "qfw/util"
 	"spider"
@@ -87,7 +88,8 @@ func InitMgoPool() {
 func InitOther() {
 	//验证码识别client
 	codegrpc.InitCodeGrpcClient()
-
+	//go执行js服务
+	gojs.InitGoRunJsClient()
 	//启动消息服务
 	spider.InitMsgClient(Config.Msgserveraddr, Config.Msgname)
 	spider.InitMsgClientFile(Config.MsgserveraddrFile, Config.Msgname+"file")