/// <summary> /// Parses out the URL to the product's image thumbnail (if one exists) // and then calls DownloadWebImage to return a BitmapImage /// </summary> /// <param name="itemHtml"></param> /// <returns></returns> public static BitmapImage GetImageThumbnail(string itemHtml) { // TODO: does Amazon use a standardized image format? // For now, allowing for multiple possible formats. string imageURLPattern = @"(http(s?):/)(/[^/]+)+\.(?:jpg|gif|png)"; string match = GetSingleRegExMatch(itemHtml, imageURLPattern); if (match.Length == 0) { return(null); } if (Uri.IsWellFormedUriString(match, UriKind.Absolute)) { Uri imageURL = new Uri(match); return(Scraper.DownloadWebImage(imageURL)); } else { return(null); } }
/// <summary> /// Given a product's unique Amazon ID, loads the review distribution histogram. /// Much faster than an entire pageload for detailed review info. /// </summary> /// <param name="asin"></param> /// <returns></returns> public static string LoadReviewHistogram(string asin) { Uri reviewHistogramPopupURL = new Uri(Constants.REVIEW_HISTOGRAM_URL + asin); return Scraper.CreateHttpRequest(reviewHistogramPopupURL); }