|
@@ -399,7 +399,10 @@ func (f *Front) SaveStep() {
|
|
|
} else if movevent, ok := util.Config.Uploadevents[f.OtherBase.SpiderMoveEvent].(string); ok && movevent != "" {
|
|
|
param["spidermovevent"] = movevent
|
|
|
}
|
|
|
-
|
|
|
+ //开发人员修改爬虫节点后,在审核人员上架时,要在原来的节点下架,临时记录要下架的节点downevent
|
|
|
+ if event := qu.IntAll((*one)["event"]); event != tmpEvent && event != 7000 {
|
|
|
+ param["downevent"] = event
|
|
|
+ }
|
|
|
//三级页复制
|
|
|
param["str_recontent"] = f.StepRe3.Expert
|
|
|
param["iscopycontent"] = f.StepRe3.Checked
|
|
@@ -522,7 +525,7 @@ func (f *Front) RunStep() {
|
|
|
}
|
|
|
if f.Method() == "POST" {
|
|
|
switch f.GetString("step") {
|
|
|
- case "step1":
|
|
|
+ case "step1": //publishtime
|
|
|
ptime := []interface{}{
|
|
|
f.Step1.DateFormat,
|
|
|
f.Step1.Address,
|
|
@@ -537,7 +540,7 @@ func (f *Front) RunStep() {
|
|
|
if err == nil {
|
|
|
f.ServeJson(rs)
|
|
|
}
|
|
|
- case "step2":
|
|
|
+ case "step2": //list
|
|
|
addrs := strings.Split(f.Step2.Listadds, "\n")
|
|
|
if len(addrs) > 0 {
|
|
|
for k, v := range addrs {
|
|
@@ -577,7 +580,7 @@ func (f *Front) RunStep() {
|
|
|
} else if err.(error).Error() == "no" {
|
|
|
f.ServeJson(rs[0])
|
|
|
}
|
|
|
- case "step3":
|
|
|
+ case "step3": //detail
|
|
|
content := []interface{}{
|
|
|
f.Step3.ContentChooser,
|
|
|
f.Step3.ElementChooser,
|
|
@@ -616,45 +619,58 @@ func (f *Front) RunStep() {
|
|
|
|
|
|
//爬虫测试数据json
|
|
|
func (f *Front) GetJson() {
|
|
|
- list, _ := f.GetSession("listInfo").([]map[string]interface{})
|
|
|
- data, _ := f.GetSession("dataInfo").(map[string]interface{})
|
|
|
- descript := f.GetSession("task_descript")
|
|
|
- remark := f.GetSession("task_remark")
|
|
|
- rateremark := f.GetSession("task_rateremark")
|
|
|
- reason := f.GetSession("reason")
|
|
|
+ code := f.GetString("code")
|
|
|
username := f.GetSession("username").(string)
|
|
|
- msg := f.GetSession(username + "_msg")
|
|
|
- if len(data) > 0 {
|
|
|
- data["contenthtml"] = ""
|
|
|
- }
|
|
|
- for k, v := range list {
|
|
|
- v["a_index"] = k + 1
|
|
|
+ if tr := TestResultMap[username+code]; tr != nil {
|
|
|
+ task, _ := u.MgoEB.FindOne("task", map[string]interface{}{"code": code, "i_state": 3})
|
|
|
+ comeintime := int64(0)
|
|
|
+ if len(*task) > 0 {
|
|
|
+ comeintime = qu.Int64All((*task)["l_comeintime"])
|
|
|
+ tr.task_remark = "审核任务创建时间:" + qu.FormatDateByInt64(&comeintime, qu.Date_Short_Layout) + ";" + tr.task_remark
|
|
|
+ }
|
|
|
+ data := tr.dataInfo
|
|
|
+ list := tr.listInfo
|
|
|
+ if len(data) > 0 {
|
|
|
+ data["contenthtml"] = ""
|
|
|
+ }
|
|
|
+ for k, v := range list {
|
|
|
+ v["a_index"] = k + 1
|
|
|
+ }
|
|
|
+
|
|
|
+ f.T["list"] = list
|
|
|
+ f.T["data"] = data
|
|
|
+ f.T["descript"] = tr.task_descript
|
|
|
+ f.T["remark"] = tr.task_remark
|
|
|
+ f.T["rateremark"] = tr.task_rateremark
|
|
|
+ f.T["reason"] = tr.reason
|
|
|
+ f.T["msg"] = tr.msg
|
|
|
+ f.T["comeintime"] = comeintime
|
|
|
+ delete(TestResultMap, username+code)
|
|
|
}
|
|
|
|
|
|
- f.T["list"] = list
|
|
|
- f.T["data"] = data
|
|
|
- f.T["descript"] = descript
|
|
|
- f.T["remark"] = remark
|
|
|
- f.T["rateremark"] = rateremark
|
|
|
- f.T["reason"] = reason
|
|
|
- f.T["msg"] = msg
|
|
|
+ f.Render("jsonInfo.html", &f.T)
|
|
|
+}
|
|
|
|
|
|
- f.DelSession("listInfo")
|
|
|
- f.DelSession("dataInfo")
|
|
|
- f.DelSession("task_descript")
|
|
|
- f.DelSession("task_remark")
|
|
|
- f.DelSession("task_rateremark")
|
|
|
- f.DelSession("reason")
|
|
|
+var TestResultMap = map[string]*TestResult{} //username+code
|
|
|
|
|
|
- f.Render("jsonInfo.html", &f.T)
|
|
|
+//某个爬虫整体测试结果
|
|
|
+type TestResult struct {
|
|
|
+ task_remark string
|
|
|
+ task_rateremark []string
|
|
|
+ task_descript string
|
|
|
+ reason string
|
|
|
+ msg string
|
|
|
+ listInfo []map[string]interface{}
|
|
|
+ dataInfo map[string]interface{}
|
|
|
}
|
|
|
|
|
|
//整体测试
|
|
|
func (f *Front) SpiderPass() {
|
|
|
defer mu.Catch()
|
|
|
+ tr := &TestResult{}
|
|
|
list := []map[string]interface{}{}
|
|
|
data := map[string]interface{}{}
|
|
|
- msg1 := ""
|
|
|
+ msgArr := []string{}
|
|
|
code := f.GetString("code")
|
|
|
downloadnode := f.GetString("node")
|
|
|
//根据code查询待确认任务
|
|
@@ -685,16 +701,15 @@ func (f *Front) SpiderPass() {
|
|
|
remark = ""
|
|
|
remark = strings.Join(remarktmp, "")
|
|
|
}
|
|
|
+ tr.task_remark = remark
|
|
|
+ tr.task_rateremark = rateremarktmp
|
|
|
+ tr.task_descript = descript
|
|
|
|
|
|
- f.SetSession("task_remark", remark)
|
|
|
- f.SetSession("task_rateremark", rateremarktmp)
|
|
|
- f.SetSession("task_descript", descript)
|
|
|
//基本信息、方法一、方法二、方法三、总请求次数、go方法一、go方法二、go方法三、列表页条数
|
|
|
steps := []interface{}{false, false, false, false, 0, 0, 0, 0, 0}
|
|
|
- //one, _ := u.MgoE.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
|
one, _ := u.MgoEB.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
|
reason, _ := (*one)["reason"].(string)
|
|
|
- f.SetSession("reason", reason)
|
|
|
+ tr.reason = reason
|
|
|
if len(*one) > 0 && (*one)["oldlua"] == nil {
|
|
|
common := (*one)["param_common"].([]interface{})
|
|
|
if len(common) < 13 {
|
|
@@ -713,17 +728,29 @@ func (f *Front) SpiderPass() {
|
|
|
script = (*one)["luacontent"].(string)
|
|
|
}
|
|
|
if liststr != "" && contentstr != "" {
|
|
|
- msg1 = u.SpiderPassCheckLua(liststr, contentstr, (*one)) //校验
|
|
|
+ msgArr = u.SpiderPassCheckLua(liststr, contentstr, (*one)) //校验
|
|
|
}
|
|
|
s := spider.CreateSpider(downloadnode, script)
|
|
|
s.SpiderMaxPage = 1
|
|
|
s.Timeout = 60
|
|
|
- time, timeerr := s.GetLastPublishTime()
|
|
|
- if timeerr == nil && len(time) > 4 {
|
|
|
+ timestr, timeerr := s.GetLastPublishTime()
|
|
|
+ if timeerr == nil && len(timestr) > 4 {
|
|
|
steps[1] = true
|
|
|
list, _ = s.DownListPageItem()
|
|
|
+ for _, l := range list {
|
|
|
+ if publishtime := qu.ObjToString(l["publishtime"]); publishtime == "0" || publishtime == "" {
|
|
|
+ msgArr = append(msgArr, "列表页publishtime取值异常")
|
|
|
+ break
|
|
|
+ } else {
|
|
|
+ t, err := time.ParseInLocation(qu.Date_Full_Layout, publishtime, time.Local)
|
|
|
+ if err != nil || t.Unix() <= 0 {
|
|
|
+ msgArr = append(msgArr, "列表页publishtime取值异常")
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if len(list) > 0 {
|
|
|
- f.SetSession("listInfo", list)
|
|
|
+ tr.listInfo = list
|
|
|
listone := list[0]
|
|
|
if len(qu.ObjToString(listone["href"])) < 7 ||
|
|
|
(qu.ObjToString(listone["publishtime"]) != "0" && len(qu.ObjToString(listone["publishtime"])) < 5) ||
|
|
@@ -744,9 +771,7 @@ func (f *Front) SpiderPass() {
|
|
|
data = map[string]interface{}{}
|
|
|
s.DownloadDetailPage(param, data)
|
|
|
if len(data) > 0 {
|
|
|
- f.SetSession("dataInfo", data)
|
|
|
- } else {
|
|
|
- f.SetSession("dataInfo", "")
|
|
|
+ tr.dataInfo = data
|
|
|
}
|
|
|
if len(data) == 0 || data["detail"].(string) == "" {
|
|
|
steps[3] = false
|
|
@@ -758,9 +783,6 @@ func (f *Front) SpiderPass() {
|
|
|
steps[3] = true
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- f.SetSession("listInfo", "")
|
|
|
- f.SetSession("dataInfo", "")
|
|
|
}
|
|
|
}
|
|
|
//关闭laustate
|
|
@@ -771,11 +793,10 @@ func (f *Front) SpiderPass() {
|
|
|
steps[7] = s.Test_goreqcon
|
|
|
//校验
|
|
|
msg := u.SpiderPassCheckListAndDetail(list, data)
|
|
|
- if msg1 != "" {
|
|
|
- msg = msg1 + ";" + msg
|
|
|
- }
|
|
|
+ msgArr = append(msgArr, msg...)
|
|
|
username := f.GetSession("username").(string)
|
|
|
- f.SetSession(username+"_msg", msg)
|
|
|
+ tr.msg = strings.Join(msgArr, ";")
|
|
|
+ TestResultMap[username+code] = tr
|
|
|
f.ServeJson(steps)
|
|
|
}
|
|
|
|
|
@@ -1060,6 +1081,7 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
|
}
|
|
|
if len(*one) > 0 {
|
|
|
var event int
|
|
|
+ unset := map[string]interface{}{}
|
|
|
if (*one)["event"] != nil {
|
|
|
event = qu.IntAll((*one)["event"])
|
|
|
} else {
|
|
@@ -1081,7 +1103,13 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
|
// }
|
|
|
upresult, err = spider.UpdateSpiderByCodeState(code, fmt.Sprint(state), event) //下架
|
|
|
qu.Debug("下架:", upresult, code)
|
|
|
- case Sp_state_5: //上架(爬虫端在更新上架的时候为了更新内存中字段,采用先下架在上架)
|
|
|
+ case Sp_state_5: //上架(爬虫端在更新上架的时候为了更新内存中字段,采用先下架上架)
|
|
|
+ if downevent := qu.IntAll((*one)["downevent"]); downevent != 0 { //爬虫开发修改爬虫节点,审核人员上架爬虫时,原来爬虫所在节点下架
|
|
|
+ upresult, err = spider.UpdateSpiderByCodeState(code, "6", downevent)
|
|
|
+ if upresult && err == nil {
|
|
|
+ unset = map[string]interface{}{"downevent": ""}
|
|
|
+ }
|
|
|
+ }
|
|
|
upresult, err = spider.UpdateSpiderByCodeState(code, "6", event)
|
|
|
qu.Debug("下架:", upresult, code)
|
|
|
if upresult && err == nil {
|
|
@@ -1101,7 +1129,13 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
|
upset := map[string]interface{}{"state": state} //修改状态
|
|
|
if (*one)["oldlua"] != nil { //老脚本上传
|
|
|
//upresult = u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, true, false)
|
|
|
- upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, true, false)
|
|
|
+ up := map[string]interface{}{
|
|
|
+ "$set": upset,
|
|
|
+ }
|
|
|
+ if len(unset) > 0 {
|
|
|
+ up["$unset"] = unset
|
|
|
+ }
|
|
|
+ upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, up, true, false)
|
|
|
} else {
|
|
|
if state == Sp_state_1 { //提交审核
|
|
|
upset["l_complete"] = time.Now().Unix()
|
|
@@ -1127,8 +1161,14 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
|
//upset["modifytime"] = time.Now().Unix()
|
|
|
upset["l_uploadtime"] = time.Now().Unix() //l_complete爬虫完成时间
|
|
|
}
|
|
|
+ up := map[string]interface{}{
|
|
|
+ "$set": upset,
|
|
|
+ }
|
|
|
+ if len(unset) > 0 {
|
|
|
+ up["$unset"] = unset
|
|
|
+ }
|
|
|
//upresult = u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
|
- upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
|
+ upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, up, false, false)
|
|
|
qu.Debug("提交日志:", code, upset, upresult)
|
|
|
if upresult && (state == Sp_state_2 || state == Sp_state_3) { //打回、审核记录日志
|
|
|
types := "打回"
|