示例#1
0
 /// <summary>
 /// Extracts all Favicons and Apple Touch Icons from a page.
 /// </summary>
 /// <param name="uri">Uri to start extracting from.</param>
 /// <param name="settings">Extraction Settings.</param>
 /// <returns>Extracted Favicons and Apple Touch Icons as instances of <see cref="WebImage"/>.</returns>
 public static async Task <IEnumerable <WebImage> > GetAllIcons(string uri, ExtractionSettings settings = null)
 {
     return(await Extract(uri, settings, async (Uri u, HtmlDocument d, ExtractionSettings s) =>
     {
         List <WebImage> favicons = await HtmlUtilities.GetFavicons(u, d, s);
         List <WebImage> appleTouchIcons = await HtmlUtilities.GetAppleTouchIcons(u, d, s);
         favicons.AddRange(appleTouchIcons);
         return favicons;
     }));
 }
示例#2
0
 /// <summary>
 /// Extracts all images from a page (including Favicons and Apple Touch Icons).
 /// </summary>
 /// <param name="uri">Uri to start extracting from.</param>
 /// <param name="settings">Extraction Settings.</param>
 /// <param name="cancellationToken">Cancellation Token.</param>
 /// <returns>Extracted images as instances of <see cref="WebImage"/>.</returns>
 public static async Task <IEnumerable <WebImage> > GetAllImages(string uri, ExtractionSettings settings = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await Extract(uri, settings, cancellationToken, async (Uri u, HtmlDocument d, ExtractionSettings s) =>
     {
         List <WebImage> favicons = await HtmlUtilities.GetFavicons(u, d, s);
         List <WebImage> appleTouchIcons = await HtmlUtilities.GetAppleTouchIcons(u, d, s);
         List <WebImage> images = await HtmlUtilities.GetPageImages(u, d, s);
         favicons.AddRange(appleTouchIcons);
         favicons.AddRange(images);
         return favicons;
     }));
 }