Please help me to find the Favicon url from the sample html below using Regular expression. It should also check for file extension ".ico". I am developing a personal bookmarking site and i want to save the favicons of links which i bookmark. I have already written the c# code to convert icon to gif and save but i have very limited knowledge about regex so i am unable to select this tag because ending tags are different in different sites . Example of ending tags "/>" "/link>"
My programming language is C#
<meta name="description" content="Create 360 degree rotation product presentation online with 3Dbin. 360 product pics, object rotationg presentation can be created for your website at 3DBin.com web service." />
<meta name="robots" content="index, follow" />
<meta name="verify-v1" content="x42ckCSDiernwyVbSdBDlxN0x9AgHmZz312zpWWtMf4=" />
<link rel="shortcut icon" href="http://3dbin.com/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="http://3dbin.com/css/1261391049/style.min.css" />
<!--[if lt IE 8]>
<script src="http://3dbin.com/js/1261039165/IE8.js" type="text/javascript"></script>
<![endif]-->
solution: one more way to do this Download and add reference to htmlagilitypack dll. Thanks for helping me. I really love this site :)
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(readcontent);
if (doc.DocumentNode != null)
{
foreach (HtmlNode link in doc.DocumentNode.SelectNodes(@"//link[@href]"))
{
HtmlAttribute att = link.Attributes["href"];
if (att.Value.EndsWith(".ico"))
{
faviconurl = att.Value;
}
}
}