|
@@ -272,6 +272,7 @@ func (f *Front) SaveStep() {
|
|
|
LuaSaveLog(f.Base.SpiderCode, user, one, 0)
|
|
|
state := qu.IntAllDef((*one)["state"], 0)
|
|
|
restate := qu.IntAll((*one)["restate"])
|
|
|
+ infoformat := qu.IntAll((*one)["infoformat"])
|
|
|
comeintime := time.Now().Unix()
|
|
|
if len((*one)) > 0 {
|
|
|
comeintime = qu.Int64All((*one)["comeintime"])
|
|
@@ -414,7 +415,7 @@ func (f *Front) SaveStep() {
|
|
|
param["iscopycontent"] = f.StepRe3.Checked
|
|
|
//
|
|
|
param["listisfilter"] = ListFilterReg.MatchString(f.Step2.Expert) //列表页校验是否含“--关键词过滤”
|
|
|
- matchLua, msg := LuaTextCheck(f.Step2.Expert, f.Step3.Expert, f.Step2.Types)
|
|
|
+ matchLua, msg := LuaTextCheck(f.Step2.Expert, f.Step3.Expert, f.Step2.Types, infoformat, model)
|
|
|
if !matchLua {
|
|
|
issave := spider.SaveSpider(code, param) //保存脚本
|
|
|
if issave {
|
|
@@ -526,20 +527,17 @@ func LuaSaveLog(code, user string, data *map[string]interface{}, stype int) {
|
|
|
}
|
|
|
|
|
|
//爬虫保存时,检查列表页和三级页代码中是否含lua原生方法
|
|
|
-func LuaTextCheck(list, detail string, type_list int) (b bool, msg string) {
|
|
|
+func LuaTextCheck(list, detail string, type_list, infoformat int, model map[string]interface{}) (b bool, msg string) {
|
|
|
defer qu.Catch()
|
|
|
if LuaReg.MatchString(list) || LuaReg.MatchString(detail) {
|
|
|
- b = true
|
|
|
msg = "代码中含有lua原生方法;"
|
|
|
}
|
|
|
if ListFilterReg.MatchString(detail) && !strings.Contains(detail, "delete") { //三级页含过滤但是没有data["delete"]="true"
|
|
|
- b = true
|
|
|
msg = `三级页缺少data["delete"]="true"`
|
|
|
}
|
|
|
sln_reg := regexp.MustCompile(`sendListNum\(pageno,list\)`)
|
|
|
slnIndexArr := sln_reg.FindAllStringIndex(list, -1)
|
|
|
if type_list != 0 && len(slnIndexArr) == 0 { //列表页专家模式且不含sendListNum
|
|
|
- b = true
|
|
|
msg = "代码中缺少sendListNum(pageno,list)方法;" + msg
|
|
|
} else if type_list == 1 && len(slnIndexArr) > 0 { //判断sendListNum方法的位置
|
|
|
trim_reg := regexp.MustCompile("trim")
|
|
@@ -552,10 +550,27 @@ func LuaTextCheck(list, detail string, type_list int) (b bool, msg string) {
|
|
|
irIndex := irIndexArr[len(irIndexArr)-1] //insert位置
|
|
|
qu.Debug("sendListNum位置:", trIndex, slIndex, irIndex)
|
|
|
if slIndex[1] < trIndex[0] || slIndex[0] > irIndex[1] { //sendListNum方法必须在com.trim方法后,table.insert方法前
|
|
|
- b = true
|
|
|
msg = "sendListNum方法位置错误;" + msg
|
|
|
}
|
|
|
}
|
|
|
+ if type_list == 1 {
|
|
|
+ area := qu.ObjToString(model["area"])
|
|
|
+ city := qu.ObjToString(model["city"])
|
|
|
+ district := qu.ObjToString(model["district"])
|
|
|
+ if area != "" && !strings.Contains(list, area) {
|
|
|
+ msg += "省份信息与模板不一致;"
|
|
|
+ }
|
|
|
+ if city != "" && !strings.Contains(list, city) {
|
|
|
+ msg += "城市信息与模板不一致;"
|
|
|
+ }
|
|
|
+ if district != "" && !strings.Contains(list, district) {
|
|
|
+ msg += "区/县信息与模板不一致;"
|
|
|
+ }
|
|
|
+ if infoformat == 2 && !strings.Contains(detail, "projectname") {
|
|
|
+ msg += "拟建/审批数据缺少projectname字段;"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ b = msg != ""
|
|
|
return
|
|
|
}
|
|
|
|