Performs page and image loads and provides methods to encode/decode strings.
예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <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);
        }