Exemple #1
0
        public void MyScrape(string scrapeDataFolder, string newScrapeDataFolder = null, bool clearOldDataFolder = false)
        {
            if (newScrapeDataFolder == null)
            {
                DataWorker.DeleteFilesFromFolder(scrapeDataFolder);
                this.menuFilesPath += scrapeDataFolder;
            }
            else
            {
                if (clearOldDataFolder)
                {
                    DataWorker.DeleteFilesFromFolder(scrapeDataFolder);
                }
                this.menuFilesPath += newScrapeDataFolder;
            }
            var scraper     = new KFCScraper();
            var scraperTask = scraper.StartAsync();

            while (true)
            {
                if (scraperTask.IsCompleted)
                {
                    break;
                }
            }

            foreach (var menuName in menu.Keys)
            {
                Scrape(menu[menuName].products, this.menuFilesPath + menuName + ".json");
            }
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            KFCScraper scraper = new KFCScraper();

            scraper.MyScrape("/ScrapersData/KFC/");

            var        scraperDataKFC = Directory.GetFiles(Directory.GetCurrentDirectory() + "/ScrapersData/KFC/");
            DishesPool dishesPool     = DishesPool.GetInstance();

            foreach (var scrapedFile in scraperDataKFC)
            {
                dishesPool.AddDishes(DataWorker.DeserialiseToDishes(scrapedFile));
            }


            CreateHostBuilder(args).Build().Run();
        }