Exemple #1
0
        public CeneoSearchResults(CeneoQuery query)
        {
            this.query = query;
            var firstPage = DownloadPageNr(0);

            items.AddRange(firstPage.shopItems);
            var pagesCount = GetPagesCount(firstPage);

            for (int i = 1; i < pagesCount; ++i)
            {
                var page = DownloadPageNr(i);
                items.AddRange(page.shopItems);
            }
        }
        static void Main()
        {
            var ui = new UserInterface();

            var input = ui.AskUserForString("Jakiego towaru mam szukać?");
            var query = new CeneoQuery(input);

            query.minimalPrice = ui.AskUserForInt("Za jaką cenę minimalną?");
            query.maximalPrice = ui.AskUserForInt("Za jaką cenę maksymalną?");

            var    ceneoSearchResults = new CeneoSearchResults(query);
            string tsv  = ceneoSearchResults.ToTsv();
            var    date = DateTime.Now;
            var    path = $"{date.ToString("yyyy-MM-dd")} - {input}.tsv";

            File.WriteAllText(path, tsv);
        }