|
@@ -544,9 +544,16 @@ func (f *Front) ImportLua() {
|
|
|
if k != 0 {
|
|
|
cells := v.Cells
|
|
|
if cells[1].Value != "" {
|
|
|
+ code := cells[1].Value
|
|
|
+ query := map[string]interface{}{"code": cells[1].Value}
|
|
|
+ rs, _ := u.MgoEB.FindOne("import", query)
|
|
|
+ if len(*rs) > 0 {
|
|
|
+ errorinfo[cells[1].Value] = "第" + strconv.Itoa(k) + "行爬虫代码重复,请修改"
|
|
|
+ continue
|
|
|
+ }
|
|
|
o := make(map[string]interface{})
|
|
|
o["name"] = cells[0].Value
|
|
|
- o["code"] = cells[1].Value
|
|
|
+ o["code"] = code
|
|
|
o["channel"] = cells[2].Value
|
|
|
channels := cells[3].Value
|
|
|
channels = strings.ReplaceAll(channels, ",", ",")
|
|
@@ -556,6 +563,7 @@ func (f *Front) ImportLua() {
|
|
|
one, _ := u.MgoEB.FindOne("luaconfig", map[string]interface{}{"href": href})
|
|
|
if len(*one) > 0 {
|
|
|
errorinfo[cells[1].Value] = "第" + strconv.Itoa(k) + "行爬虫" + cells[1].Value + ",该栏目已存在,请确认"
|
|
|
+ continue
|
|
|
}
|
|
|
o["channeladdr"] = href
|
|
|
o["author"] = cells[5].Value
|
|
@@ -582,25 +590,23 @@ func (f *Front) ImportLua() {
|
|
|
o["weight"] = weigh
|
|
|
//爬虫类型
|
|
|
infoformat, _ := cells[15].Int()
|
|
|
+ if infoformat < 1 {
|
|
|
+ errorinfo[cells[1].Value] = "第" + strconv.Itoa(k) + "行爬虫" + cells[1].Value + ",缺少爬虫类型信息"
|
|
|
+ continue
|
|
|
+ }
|
|
|
o["infoformat"] = infoformat
|
|
|
//存储表
|
|
|
o["coll"] = cells[16].Value
|
|
|
//table := cells[6].Value
|
|
|
//o["table"] = table
|
|
|
//o["transfercode"] = qu.IntAll(Transfercode[table])
|
|
|
- query := map[string]interface{}{"code": cells[1].Value}
|
|
|
- rs, _ := u.MgoEB.FindOne("import", query)
|
|
|
- if len(*rs) > 0 {
|
|
|
- errorinfo[cells[1].Value] = "第" + strconv.Itoa(k) + "行重复,已经过滤"
|
|
|
+ ok, name := saveLua(o) //保存爬虫
|
|
|
+ if ok == false {
|
|
|
+ errorinfo[cells[1].Value] = "第" + strconv.Itoa(k) + "行找不到作者,已经过滤"
|
|
|
} else {
|
|
|
- ok, name := saveLua(o) //保存爬虫
|
|
|
- if ok == false {
|
|
|
- errorinfo[cells[1].Value] = "第" + strconv.Itoa(k) + "行找不到作者,已经过滤"
|
|
|
- } else {
|
|
|
- o["author"] = name
|
|
|
- o["importuser"] = f.GetSession("username")
|
|
|
- u.MgoEB.Save("import", o)
|
|
|
- }
|
|
|
+ o["author"] = name
|
|
|
+ o["importuser"] = f.GetSession("username")
|
|
|
+ u.MgoEB.Save("import", o)
|
|
|
}
|
|
|
}
|
|
|
}
|