Example #1
0
        private static void InitSystem()
        {
            try
            {
                dynamic type = (new Program()).GetType();
                _CurrentDirectory = Path.GetDirectoryName(type.Assembly.Location);

                _configuration = Configuration.SetBasePath(_CurrentDirectory)
                                 .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                                 .Build();

                var serviceCollection = new ServiceCollection();
                serviceCollection.AddSqlSugarSetup(_configuration);
                serviceCollection.AddCrawlers(_configuration);
                serviceCollection.AddRepository(_configuration);
                serviceCollection.AddInitDbSeed(_configuration);
                serviceCollection.AddMemoryCache();
                //  serviceCollection.AddScoped<IConfiguration>(_configuration);
                //

                _ServiceProvider      = serviceCollection.BuildServiceProvider();
                _DouBanBookRepository = _ServiceProvider.GetService <DouBanBookService>();
                _Db = _ServiceProvider.GetService <SqlSugarClient>();

                var list = _ServiceProvider.GetService <IEnumerable <ICrawlerBatchBook> >();
                _LatestBatchBook = list.FirstOrDefault(a => a.GetType().Name == "BookLatestCrawler");
                _TagList         = list.FirstOrDefault(a => a.GetType().Name == "TagListCrawler");
                _DetailBook      = _ServiceProvider.GetService <ICrawlerBook>();
                _CrawlerTag      = _ServiceProvider.GetService <ICrawlerTag>();
                _DaReTouCrawler  = _ServiceProvider.GetService <DaReTouCrawler>();
            }
            catch (Exception ex)
            {
                NLogUtil.ErrorTxt($"Init Error:{ex.Message}", true);
            }
        }
Example #2
0
 public SinglgTask(ICrawlerBook crawlerDetail,
                   DouBanBookService douBanBookRepository)
 {
     _DouBanBookRepository = douBanBookRepository;
     _DetailCrawler        = crawlerDetail;
 }
 public BookLatestCrawler(ICrawlerBook crawlerBook)
 {
     _CrawlerBook = crawlerBook;
 }
Example #4
0
 public TagListCrawler(ICrawlerBook crawlerBook)
 {
     _CrawlerBook = crawlerBook;
 }
Example #5
0
        public BookDetail_middle ToDetail(string url, ICrawlerBook crawlerBook)
        {
            var r = crawlerBook.Crawler(url);

            return(r);
        }