|
@@ -14,6 +14,15 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
+// QlmStopDownloadData 终止下载
|
|
|
+func (a *App) QlmStopDownloadData(record map[string]interface{}) *Result {
|
|
|
+ r := &Result{}
|
|
|
+ qu.Debug(record)
|
|
|
+ glvm.CloseTabs() //关闭浏览器资源
|
|
|
+ r.Err = 1
|
|
|
+ return r
|
|
|
+}
|
|
|
+
|
|
|
// QlmListDataDownload 千里马列表页数据下载
|
|
|
func (a *App) QlmListDataDownload(param map[string]interface{}, record map[string]interface{}) *Result {
|
|
|
qu.Debug(param, record)
|
|
@@ -23,10 +32,10 @@ func (a *App) QlmListDataDownload(param map[string]interface{}, record map[strin
|
|
|
page := "list"
|
|
|
detailScript := glvm.LoadScript("list")
|
|
|
if detailScript != "" {
|
|
|
- //getResult(map[string]interface{}{"param": param, "user": User}, r, "qlm/updateRecord")
|
|
|
- //if r.Err == 1 {
|
|
|
- go DownloadData(record, detailScript, page) //下载
|
|
|
- //}
|
|
|
+ getResult(map[string]interface{}{"param": param, "user": User}, r, "qlm/updateRecord")
|
|
|
+ if r.Err == 1 {
|
|
|
+ go DownloadData(record, detailScript, page) //下载
|
|
|
+ }
|
|
|
} else {
|
|
|
r.Msg = "详情页采集脚本加载失败!"
|
|
|
}
|
|
@@ -35,7 +44,6 @@ func (a *App) QlmListDataDownload(param map[string]interface{}, record map[strin
|
|
|
}
|
|
|
} else {
|
|
|
r.Msg = "用户登录异常,请重新登录!"
|
|
|
- qu.Debug(r.Msg)
|
|
|
}
|
|
|
return r
|
|
|
}
|
|
@@ -50,12 +58,12 @@ func (a *App) QlmDetailDataDownload(param map[string]interface{}, record map[str
|
|
|
detailScript := glvm.LoadScript("detail")
|
|
|
if detailScript != "" {
|
|
|
script.Datas = []map[string]interface{}{}
|
|
|
- getData(nil, qu.ObjToString(record["recordId"]), "json", "download", &script.Datas)
|
|
|
+ getData(nil, qu.ObjToString(record["recordid"]), "json", "download", &script.Datas)
|
|
|
if len(script.Datas) > 0 {
|
|
|
r.Err = 1
|
|
|
go DownloadData(record, detailScript, page) //下载
|
|
|
} else {
|
|
|
- r.Msg = "未获取到列表页数据!"
|
|
|
+ r.Msg = "无可采集数据!"
|
|
|
}
|
|
|
//getResult(map[string]interface{}{"param": param, "user": User}, r, "qlm/updateRecord")
|
|
|
} else {
|
|
@@ -80,18 +88,19 @@ func DownloadData(record map[string]interface{}, scriptText, page string) {
|
|
|
glvm.ProxyServer, _ = record["proxyServer"].(bool)
|
|
|
glvm.Headless, _ = record["headless"].(bool)
|
|
|
glvm.ShowImage, _ = record["showImage"].(bool)
|
|
|
- recordId := qu.ObjToString(record["recordId"])
|
|
|
+ recordId := qu.ObjToString(record["recordid"])
|
|
|
//执行脚本
|
|
|
glvm.RunScript(scriptText, recordId)
|
|
|
for len(script.DataCache) > 0 {
|
|
|
+ qu.Debug("当前待保存数据量:", len(script.DataCache))
|
|
|
time.Sleep(time.Second * 1)
|
|
|
}
|
|
|
- //state := 2
|
|
|
- //if page == "detail" {
|
|
|
- // state = 5
|
|
|
- //}
|
|
|
- //r := &Result{}
|
|
|
- //getResult(map[string]interface{}{"param": map[string]interface{}{"recordid": recordId, "state": state}}, r, "qlm/updateRecord")
|
|
|
+ state := 2
|
|
|
+ if page == "detail" {
|
|
|
+ state = 5
|
|
|
+ }
|
|
|
+ r := &Result{}
|
|
|
+ getResult(map[string]interface{}{"param": map[string]interface{}{"recordid": recordId, "state": state}}, r, "qlm/updateRecord")
|
|
|
}
|
|
|
|
|
|
// QlmRunExportExcelFile 导出excel
|
|
@@ -189,14 +198,18 @@ func getData(file *excelize.File, recordId, exportStype, from string, result *[]
|
|
|
file.SetCellStr("Sheet1", "A"+indexStr, qu.ObjToString(tmp["_id"]))
|
|
|
file.SetCellStr("Sheet1", "B"+indexStr, qu.ObjToString(tmp["title"]))
|
|
|
file.SetCellStr("Sheet1", "C"+indexStr, qu.ObjToString(tmp["href"]))
|
|
|
- publishtime := qu.Int64All(tmp["publishtime"])
|
|
|
- if publishtime == 0 {
|
|
|
- file.SetCellStr("Sheet1", "D"+indexStr, "")
|
|
|
+ if ptime, ok := tmp["publishtime"].(string); ok {
|
|
|
+ file.SetCellStr("Sheet1", "D"+indexStr, ptime)
|
|
|
} else {
|
|
|
- file.SetCellStr("Sheet1", "D"+indexStr, qu.FormatDateByInt64(&publishtime, qu.Date_Full_Layout))
|
|
|
+ publishtime := qu.Int64All(tmp["publishtime"])
|
|
|
+ if publishtime == 0 {
|
|
|
+ file.SetCellStr("Sheet1", "D"+indexStr, "")
|
|
|
+ } else {
|
|
|
+ file.SetCellStr("Sheet1", "D"+indexStr, qu.FormatDateByInt64(&publishtime, qu.Date_Full_Layout))
|
|
|
+ }
|
|
|
}
|
|
|
repeatText := ""
|
|
|
- if repeat := tmp["repeat"]; repeat != nil {
|
|
|
+ if repeat := tmp["rp"]; repeat != nil {
|
|
|
if repeatTmp, ok := repeat.(bool); ok && repeatTmp {
|
|
|
repeatText = "重复"
|
|
|
} else {
|