嘿所有, 我只是想知道,有没有一个正确的方法来获取网站的favicon而不是从
http + Url.Host + / favicon.ico?我知道网站通常设置这样的图标:
< meta content = / images / myfavicon.png itemprop = image > OR < link rel = icon type = image / x-icon href = / myfavicon.ico >有没有办法搜索网站的HTML代码和使用CEF(用于VB.NET WinForms的ChromiumEmbedFramework)或webclient获取这些标签中的图标(我仍然不确定如何使用CEF从网站获取源代码)。 我真的很感激任何帮助! :D
解决方案好的,我自己弄清楚了。我决定使用webclient并使用Google的Api来获取网站图标: Dim Urlh As 新 Uri( www.google/s2/favicons?domain= + 新 Uri(Browser.Address)。主持人) Dim Img As Image = 新位图(新 IO.MemoryStream(新 WebClient() .DownloadData(Urlh))) Dim Img2 As 新位图(Img) Dim Img3 As 图标 Dim oIcon As Icon = Img 3.FromHandle(Img2.GetHicon) 我 .Icon = oIcon
希望这可以帮助其他人! ;)
Hey all, I was just wondering, is there a proper way to get a website's favicon without just getting it from
"http" + Url.Host + "/favicon.ico"? I know that a website usually sets its favicon like this:
<meta content="/images/myfavicon.png" itemprop="image"> OR <link rel="icon" type="image/x-icon" href="/myfavicon.ico">Is there a way I can search through the website's HTML code and get the icon from those tags using CEF (ChromiumEmbedFramework for VB.NET WinForms) or a webclient (I'm still not sure how to get the source code from a website using CEF). I would really appreciate any help! :D
解决方案 Ok, I managed to figure it out myself. I decided to use a webclient and use Google's Api to get the website favicon: Dim Urlh As New Uri("www.google/s2/favicons?domain=" + New Uri(Browser.Address).Host) Dim Img As Image = New Bitmap(New IO.MemoryStream(New WebClient().DownloadData(Urlh))) Dim Img2 As New Bitmap(Img) Dim Img3 As Icon Dim oIcon As Icon = Img3.FromHandle(Img2.GetHicon) Me.Icon = oIconHope this helps anyone else! ;)
更多推荐
使用CEF以正确的方式获取网站图标
发布评论