private async Task <IList <ProductInfo> > GetProductsInfo(IList <CategoryProduct> categorieProduct) { var result = new List <ProductInfo>(categorieProduct.Count); foreach (var catProd in categorieProduct) { if (Uri.TryCreate(catProd.Url, UriKind.Absolute, out Uri uri)) { try { PageChangded.Invoke(this, uri); var propuctPage = await _loader.LoadPageAsync(catProd.Url); var product = await CreateProduct(propuctPage); product.Url = catProd.Url; product.RawHtml = propuctPage; result.Add(product); } catch (Exception ex) { Error.Invoke(this, ex.Message); } } } return(result); }
private void RaisePage(Uri url) { try { PageChangded.Invoke(this, url); } catch { } }
private async Task <IList <CategoryProduct> > GetCategoriesProducts() { var result = new List <CategoryProduct>(); foreach (var item in CategoriesUrl) { try { if (Uri.TryCreate(item.Value, UriKind.Absolute, out Uri uri)) { PageChangded.Invoke(this, uri); var categoriePage = await _loader.LoadPageAsync(item.Value); var productsListItems = await _parser.ParseHtmlAsync(categoriePage, CategoryProduct.ProductListSelector); foreach (var productItem in productsListItems) { try { var productInfo = await CreateCategoryProduct(productItem); result.Add(productInfo); } catch (Exception ex) { Error.Invoke(this, ex.Message); } } } } catch (Exception ex) { Error.Invoke(this, ex.Message); } } return(result); }