|
@@ -241,6 +241,12 @@ func (s *Script) LoadScript(code, script_file string, newstate bool) string {
|
|
|
S.Push(ret)
|
|
|
return 1
|
|
|
}))
|
|
|
+ //推送列表页下载数据量
|
|
|
+ s.L.SetGlobal("sendListNum", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
+ //table := S.ToTable(-1)
|
|
|
+ //list := util.TableToMap(table)
|
|
|
+ return 1
|
|
|
+ }))
|
|
|
// s.L.SetGlobal("findMgoData", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
// update := [][]map[string]interface{}{}
|
|
|
// query := map[string]interface{}{"state": 0}
|
|
@@ -329,6 +335,7 @@ func (s *Script) LoadScript(code, script_file string, newstate bool) string {
|
|
|
str := S.CheckString(-1)
|
|
|
switch codeType {
|
|
|
case "unicode":
|
|
|
+ str = strings.Replace(str, "%u", "\\u", -1)
|
|
|
str = transUnic(str)
|
|
|
case "urlencode_gbk":
|
|
|
data, _ := ioutil.ReadAll(transform.NewReader(bytes.NewReader([]byte(str)), simplifiedchinese.GBK.NewEncoder()))
|
|
@@ -787,19 +794,61 @@ func (s *Script) LoadScript(code, script_file string, newstate bool) string {
|
|
|
}))
|
|
|
//获取验证码
|
|
|
s.L.SetGlobal("getCodeByPath", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
- head := S.ToTable(-1)
|
|
|
- path := S.ToString(-2)
|
|
|
+ cookie := S.ToString(-1)
|
|
|
+ head := S.ToTable(-2)
|
|
|
+ stype := S.ToString(-3)
|
|
|
+ path := S.ToString(-4)
|
|
|
headMap := util.GetTable(head)
|
|
|
- qu.Debug(headMap)
|
|
|
+ //qu.Debug("cookie----------", cookie)
|
|
|
+ //qu.Debug("headMap----------", headMap)
|
|
|
headJsonStr := ""
|
|
|
headByte, err := json.Marshal(headMap)
|
|
|
if err == nil {
|
|
|
headJsonStr = string(headByte)
|
|
|
}
|
|
|
- code := codegrpc.GetCodeByPath(path, headJsonStr)
|
|
|
+ code, respHead, respCookie := codegrpc.GetCodeByPath(path, stype, headJsonStr, cookie)
|
|
|
+ //qu.Debug("code====", code)
|
|
|
+ //qu.Debug("respHead====", respHead)
|
|
|
+ //qu.Debug("respCookie====", respCookie)
|
|
|
S.Push(lua.LString(code))
|
|
|
- return 1
|
|
|
+ respHeadMap := map[string]interface{}{}
|
|
|
+ json.Unmarshal([]byte(respHead), &respHeadMap)
|
|
|
+ hTable := util.MapToLuaTable(S, respHeadMap)
|
|
|
+ S.Push(hTable)
|
|
|
+ S.Push(lua.LString(respCookie))
|
|
|
+ return 3
|
|
|
}))
|
|
|
+ s.L.SetGlobal("newDownloadFile", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
+ cookie := S.ToString(-1)
|
|
|
+ head := S.ToTable(-2)
|
|
|
+ param := S.ToTable(-3)
|
|
|
+ method := S.ToString(-4)
|
|
|
+ url := S.ToString(-5)
|
|
|
+ fileName := S.ToString(-6)
|
|
|
+ ishttps := strings.Contains(url, "https")
|
|
|
+ var mycookie []*http.Cookie
|
|
|
+ if cookie != "{}" {
|
|
|
+ json.Unmarshal([]byte(cookie), &mycookie)
|
|
|
+ } else {
|
|
|
+ mycookie = make([]*http.Cookie, 0)
|
|
|
+ }
|
|
|
+ fileName = strings.TrimSpace(fileName)
|
|
|
+ url = strings.TrimSpace(url)
|
|
|
+ ret := NewDownloadFile(s.Downloader, url, method, util.GetTable(param), util.GetTable(head), mycookie, s.Encoding, false, ishttps, "", s.Timeout, false)
|
|
|
+ url, name, size, ftype, fid := util.UploadFile(s.SCode, fileName, url, ret)
|
|
|
+ if strings.TrimSpace(ftype) == "" {
|
|
|
+ if len(path.Ext(name)) > 0 {
|
|
|
+ ftype = path.Ext(name)[1:]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ S.Push(lua.LString(url))
|
|
|
+ S.Push(lua.LString(name))
|
|
|
+ S.Push(lua.LString(size))
|
|
|
+ S.Push(lua.LString(ftype))
|
|
|
+ S.Push(lua.LString(fid))
|
|
|
+ return 5
|
|
|
+ }))
|
|
|
+
|
|
|
return ""
|
|
|
}
|
|
|
func dealHref(pageListUrl, href string) string {
|