You can use HTML agility pack or XmlDocument and get favicon. The following code will bring the path of website’s icon.
public JsonResult GetFavIcon(string term)
{
string htmlCode;
try
{
using (WebClient client = new WebClient())
{
htmlCode = client.DownloadString(term);
}
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(htmlCode);
if (doc.DocumentNode != null)
{
var favicon = "/favicon.ico";
var el =doc.DocumentNode.SelectSingleNode("/html/head/link[@rel='shortcut icon' and@href]");
}
return Json(submit, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
return null;
}
}
Post your comments / questions
Recent Article
- Fix-Gradient effect turning to gray in after effects
- How to blur an image in python?
- ModuleNotFoundError: No module named 'whois' in Python GoviralHost Without Terminal
- How to Convert Image to Pencil Sketch in Python?
- AttributeError: module 'urllib' has no attribute 'request' - Python
- How to Extract audio from video files using python?
- PermissionError: [Errno 13] Permission denied: 'shampoo_sales.csv' - Python
- [WinError 145] The directory is not empty: 'FolderPath' - Python
Related Article