Imports System.Net Imports System.IO Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.WebBrowser1.Navigate("http://blogs.dion.ne.jp/anis7742/") End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted For Each linkTag As HtmlElement In Me.WebBrowser1.Document.GetElementsByTagName("link") Dim relAttribute As String = linkTag.GetAttribute("rel") Dim iconUrl As String If relAttribute = "shortcut icon" OrElse relAttribute = "icon" Then iconUrl = linkTag.GetAttribute("href") If iconUrl.StartsWith("http") Then '完全なURLの場合 Me.Icon = getIconFromUrl(iconUrl) ElseIf iconUrl.StartsWith("/") Then '絶対URLの場合 Me.Icon = getIconFromUrl("http://" + e.Url.Host + iconUrl) Else '相対URLの場合 Me.Icon = getIconFromUrl(e.Url.ToString() + iconUrl) End If Exit For End If Next 'タグでの指定が無い場合 Me.Icon = getIconFromUrl("http://" + e.Url.Host + "/favicon.ico") End Sub Private Function getIconFromUrl(ByVal url As String) As Icon Using webClient As New WebClient Dim icondata As Byte() = webClient.DownloadData(url) Using stream As New MemoryStream(icondata) Return New Icon(stream) End Using End Using End Function End Class