                     
                     (head,foot) = try String(contentsOf:url!).contains(string: "<span class=\"all hidden\">") ? ("<span class=\"all hidden\">","</span>") : ("<span property=\"v:summary\" class=\"\">","</span>")
                     
-                    _ = self.scanWith(head:head,foot:foot,scanner:scanner).components(separatedBy: "<br />").map{
+                    _ = self.scanWith(data:data,head:head,foot:foot).first!.components(separatedBy: "<br />").map{
                         intro += $0.trimmingCharacters(in: .whitespacesAndNewlines)
                     }
                     
                     
-                    doMongoDB
+                    doMongoDB{
+                        
+                        let selector = try BSON(json:"{\"id\":\(id)}")
+                        //数据已满
+                        if let count = $0.find()?.reversed().count,count > 9
                         {
-                            let selector = try BSON(json:"{\"id\":\(id)}")
-                            //数据已满
-                            if let count = $0.find()?.reversed().count,count > 9
+                            for x in $0.find(query: selector)!
                             {
-                                for x in $0.find(query: selector)!
-                                {
-                                    if x.asString.isEmpty { serverPush.shared.beginPush() }
-                                }
+                                if x.asString.isEmpty { serverPush.shared.beginPush() }
                             }
-                            else
+                        }
+                        else
+                        {
+                            if case .success = $0.update(selector: selector, update: try BSON(json: "{\"id\":\(id),\"content\":{\(content)},\"intro\":\"\(intro)\"}"), flag: .upsert) {} else
                             {
-                                if case .success = $0.update(selector: selector, update: try BSON(json: "{\"id\":\(id),\"content\":{\(content)},\"intro\":\"\(intro)\"}"), flag: .upsert) {} else
-                                {
-                                    throw crawlerError(msg: "数据保存有误")
-                                }
+                                throw crawlerError(msg: "数据保存有误")
                             }
+                        }
                     }
                 }
                 catch

                }
            }
            index += 1

            }
            
//            DispatchQueue.global().sync
//            {
//                do
//                {
//                    let scanner = Scanner(string: try String(contentsOf:url!))
//                    var (head,foot) = ("data-name=",".jpg")
//                    
//                    //电影模型
//                    var tempStr = (head + self.scanWith(head:head,foot:foot,scanner:scanner) + foot).components(separatedBy: "data-").map{
//                        "\"\($0)".replacingOccurrences(of: "=", with: "\":").trim(string:" ")
//                    }
//                    
//                    tempStr.removeFirst()
//                    
//                    var content = ""
//                    
//                    _ = tempStr.map{ content += "\($0),\n" }
//                    
//                    var id = 0
//                    
//                    for str in tempStr
//                    {
//                        if str.contains("href")
//                        {
//                            id = Int(str.components(separatedBy: ":").last!.components(separatedBy: "/").dropLast().last!)!
//                        }
//                    }
//                    
//                    content = content.replace(of: ",", with: "\"")
//                    
//                    //电影简介
//                    var intro = ""
//                    
//                    (head,foot) = try String(contentsOf:url!).contains(string: "<span class=\"all hidden\">") ? ("<span class=\"all hidden\">","</span>") : ("<span property=\"v:summary\" class=\"\">","</span>")
//                    
//                    _ = self.scanWith(head:head,foot:foot,scanner:scanner).components(separatedBy: "<br />").map{
//                        intro += $0.trimmingCharacters(in: .whitespacesAndNewlines)
//                    }
//                    
//                    
//                    doMongoDB
//                        {
//                            let selector = try BSON(json:"{\"id\":\(id)}")
//                            //数据已满
//                            if let count = $0.find()?.reversed().count,count > 9
//                            {
//                                for x in $0.find(query: selector)!
//                                {
//                                    if x.asString.isEmpty { serverPush.shared.beginPush() }
//                                }
//                            }
//                            else
//                            {
//                                if case .success = $0.update(selector: selector, update: try BSON(json: "{\"id\":\(id),\"content\":{\(content)},\"intro\":\"\(intro)\"}"), flag: .upsert) {} else
//                                {
//                                    throw crawlerError(msg: "数据保存有误")
//                                }
//                            }
//                    }
//                }
//                catch
//                {
//                    debugPrint(error)
//                }
//            }
//            index += 1
//        }
        
        debugPrint("获取信息结束")
    }
    
    private func scanWith(head:String,foot:String,scanner:Scanner)->String
    {
        var str:NSString?
        
        scanner.scanUpTo(head, into: nil)
        scanner.scanUpTo(foot, into: &str)
        
        return str == nil ? "" : str!.replacingOccurrences(of: head, with: "")
    }
}


        for case let url in data.map({ URL(string:$0) })
        {
            guard let _ = url else { throw crawlerError(msg:"数据\(index)初始化失败") }
            
            Threading.getQueue(name: "sync", type: .serial).dispatch{
                
                do{
                    let data = try String(contentsOf:url!)
                    
                    var (head,foot) = ("data-name=",".jpg")
                    
                    //电影模型
                    var tempStr = (head + self.scanWith(data:data, head: head, foot: foot).first! + foot).components(separatedBy: "data-").map{
                        "\"\($0)".replacingOccurrences(of: "=", with: "\":").trim(string:" ")
                    }
                    
