コード例 #1
0
ファイル: Program.cs プロジェクト: h3r0ld/QuoteCrawler
        public static async Task ProcessQuotes(List <string> authors, int maxQuoteLength, string firebaseHost)
        {
            // Get max page numbers for every author
            PagingSpider pagingSpider = new PagingSpider(authors);

            pagingSpider.Run();

            // Convert the result to PagingEntity objects
            var pagingEntities = pagingSpider.CollectionEntityPipeline.ToEntityList <PagingEntity>();

            // Get all quotes from all pages for the author
            QuoteSpider quoteSpider = new QuoteSpider(pagingEntities.ToList())
            {
                ThreadNum = 4
            };

            quoteSpider.Run();

            // Convert the result to FirebaseQuote objects
            var firebaseQuotes = quoteSpider.CollectionEntityPipeline.ToFirebaseQuotes(maxQuoteLength);

            // Delete all existing quotes from firebase, then upload all quotes
            var firebaseService = new FirebaseService(firebaseHost);
            await firebaseService.ReUpload(firebaseQuotes, batchSize : 50);
        }