|
@@ -44,6 +44,7 @@ func init() {
|
|
|
InitMgo()
|
|
|
//InitEs()
|
|
|
InitMysql()
|
|
|
+ initSpider()
|
|
|
//
|
|
|
|
|
|
}
|
|
@@ -119,5 +120,32 @@ func InitMgo() {
|
|
|
}
|
|
|
MgoP.InitPool()
|
|
|
|
|
|
+ MgoSpider = &mongodb.MongodbSim{
|
|
|
+ MongodbAddr: GF.Mongospider.Host,
|
|
|
+ DbName: GF.Mongospider.DB,
|
|
|
+ Size: 10,
|
|
|
+ UserName: GF.Mongospider.Username,
|
|
|
+ Password: GF.Mongospider.Password,
|
|
|
+ }
|
|
|
+ MgoSpider.InitPool()
|
|
|
+
|
|
|
log.Info("InitMgo", zap.Any("duration", time.Since(now).Seconds()))
|
|
|
}
|
|
|
+
|
|
|
+//initSpider 初始化 竞品站点
|
|
|
+func initSpider() {
|
|
|
+ fmt.Println("开始初始化 -- 竞品站点")
|
|
|
+ sess := MgoSpider.GetMgoConn()
|
|
|
+ defer MgoSpider.DestoryMongoConn(sess)
|
|
|
+ query := sess.DB(GF.Mongospider.DB).C(GF.Mongospider.Coll).Find(nil).Iter()
|
|
|
+ count := 0
|
|
|
+
|
|
|
+ for tmp := make(map[string]interface{}); query.Next(tmp); count++ {
|
|
|
+ if tmp["site"] != nil {
|
|
|
+ site := tmp["site"].(string)
|
|
|
+ SpiderSites = append(SpiderSites, site)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Info("initSpider", zap.Int("初始化竞品站点完毕,竞品网站数量为:", len(SpiderSites)))
|
|
|
+
|
|
|
+}
|