public async Task <List <Apartment> > GetAsync(string url) { HttpResponseMessage data = await engine.LoadAsync(url); var kufarApartments = await parser.ParseAsync <KufarBoard>(data); var results = new List <Apartment>(); foreach (var flat in kufarApartments.Apartments) { var detailsUrl = "https://re.kufar.by/api/search/detail/" + flat.Id; var detailsData = await engine.LoadAsync(detailsUrl); var details = await parser.ParseAsync <KufarDetails>(detailsData); if (details == null) { logger.LogWarning($"Details are abscent for kufar item: {flat.Address}, url: {flat.Url}"); } var result = flat.ToApartment(details?.Result); if (details != null && result.Phones.Count == 0) { logger.LogWarning($"Item {result} does not contain proper phone number in details {details.Result}"); } results.Add(result); } return(results); }
public async Task <List <Apartment> > GetAsync(string url) { HttpResponseMessage data = await engine.LoadAsync(url); var parsed = await parser.ParseAsync <OnlinerBoard>(data); List <Apartment> apartments = parsed.Apartments.Select(x => x.ToApartment()).ToList(); foreach (var flat in apartments) { var response = await engine.LoadAsync(flat.Uri.AbsoluteUri); var content = await parser.GetContentAsync(response); flat.Phones = pageParser.FindByRegex(content, new PhoneRegex().Expression).ToList(); } return(apartments); }