public async Task ParseCarPhotosAsync(List <IHtmlDocument> documents, string[] carIds, string wwwroot) { var url = "https://www.happycarservice.com/"; if (!Directory.Exists(wwwroot)) { Directory.CreateDirectory(wwwroot); } var i = 0; foreach (var document in documents) { var vehicle = await _vehicleService.GetByExternalId(carIds[i]); IEnumerable <IElement> items = document.QuerySelectorAll("div.sliderkit-panel"); var path = Directory.CreateDirectory( Path.Combine(wwwroot, WorkContext.ImagePath, vehicle.Id.ToString())); foreach (var item in items) { var carSource = item.OuterHtml.Substring(87, 47); var carUrl = url + carSource; var photoName = carSource.Substring(26); DownloadPhoto(carUrl, path.FullName, photoName); await _photoService.AddByParser(photoName, vehicle.Id, wwwroot); } i++; } }