28
1
using System;
2
using HtmlAgilityPack;
3
using System.Net;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
// website URL
10
var html = @"https://www.TechnologyCrowds.com/";
11
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
12
13
// declare htmlweb and load html document
14
HtmlWeb web = new HtmlWeb();
15
var htmlDoc = web.Load(html);
16
17
var favicon = (dynamic)null;
18
// extracting icon
19
var el = htmlDoc.DocumentNode.SelectSingleNode("/html/head/link[@rel='icon' and @href]");
20
if (el != null)
21
{
22
favicon = el.Attributes["href"].Value;
23
24
// showing output here
25
Console.WriteLine(Convert.ToString(favicon));
26
}
27
}
28
}
Cached Result