예제 #1
0
        public async Task StartAsync(string url)
        {
            ListAdvertisements listAdvertisements = new ListAdvertisements();

            do
            {
                if (listAdvertisements.UrlNextPage != default)
                {
                    url = listAdvertisements.UrlNextPage;
                }

                string html = await DownloadHtml(url);

                listAdvertisements = ParsingListAdvertisement(html);

                repository.AddListAdvertisement(listAdvertisements);
            } while (listAdvertisements.ExistNextPage);

            // Парсим отдельно каждое объявление
            var urls = repository.GetUnfinishedAdvertisementUrls();

            foreach (var item in urls)
            {
                string html = await DownloadHtml(item);

                Advertisement advertisement = await ParsingAdvertisementAsync(html);

                advertisement.Url = item;
                repository.AddAdvertisement(advertisement);
            }
        }