DownloadWebImage() public static méthode

public static DownloadWebImage ( Uri url ) : BitmapImage
url System.Uri
Résultat System.Windows.Media.Imaging.BitmapImage
Exemple #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);
            }
        }