示例#1
0
        public async Task <ProductDetails> GetProductDetailsBySKUAsync(string productDetailsUrl, string urlParams, int sku)
        {
            var formattedSKU = skuFormatter.GetFormattedSKUString(sku);
            var productUrl   = $"{productDetailsUrl}{urlParams}{formattedSKU}";

            var downloadTask = await httpClient.DownloadDocumentAsyn(productUrl);

            var content = downloadTask;

            contentReader.SetContext(content);

            var productDetails = new ProductDetails();

            productDetails.SKU      = sku;
            productDetails.Url      = productUrl;
            productDetails.Title    = contentReader.ReadContent("<title>", " - Product Details").Trim();
            productDetails.ImageUrl = contentReader.ReadContent("<a class=\"change-cursor\" href=\"", "\">").Trim();

            return(productDetails);
        }