(self, reason)
:param reason:
        :return:所有url请求完毕之后关闭爬虫的回调函数
:param reason:
        :return:所有url请求完毕之后关闭爬虫的回调函数
: param reason : : return : 所有url请求完毕之后关闭爬虫的回调函数
def close(self, reason):
        """
        :param reason:
        :return:所有url请求完毕之后关闭爬虫的回调函数
        """
        time_gap = time()-self.crawler_begin_time
        if self.crawler_parse_counter != 0:
            print("%s爬虫关闭 用时%d 共计爬取%d 平均%f"%(self.name, time_gap, self.crawler_parse_counter, time_gap/self.crawler_parse_counter))
        from instance.global_instance import gs
        print("正在为 %s 创建索引..."%(self.current_nickname))
        index_result = gs.index_db_docs(self.current_nickname)
        print("索引完成",index_result)
        from db.meta_data import insert_article_metadata
        insert_article_metadata(self.current_nickname,{'date':datetime.datetime.now(),'articles_num':self.crawler_parse_counter})
def close ( self , reason ) : time_gap = time ( ) - self . crawler_begin_time if self . crawler_parse_counter != 0 : print ( "%s爬虫关闭 用时%d 共计爬取%d 平均%f"%(self.name, time_gap, s e l f.cr a wler _ arse_cou n er,  t ime_gap/self.crawler_ p rse_coun t er)) from instance . global_instance import gs print ( "正在为 %s 创建索引..."%(self.current _ n ickn a me)) index_result = gs . index_db_docs ( self . current_nickname ) print ( "索引完成",index_r e sult) from db . meta_data import insert_article_metadata insert_article_metadata ( self . current_nickname , { 'date' : datetime . datetime . now ( ) , 'articles_num' : self . crawler_parse_counter } )