Site hosted by Angelfire.com: Build your free website today!

Knowing META tags contents

Meta Tags - Internet Explorer
Create a new Standard exe project.
Add a reference to Microsoft HTML Object Library.
Add a reference to Microsoft Internet Controls.
Add the following controls:
2 TextBox
1 CommandButton
1 ListBox
Your form could be like this:



This little app shows the names and contents of meta-tags for a given page. It only works with Internet Explorer.
Option Explicit
Dim WithEvents IE As InternetExplorer
Dim oMetaTags() As HTMLMetaElement
Dim sUrl As String

Private Sub Command1_Click()
IE.navigate Text1.Text
End Sub

Private Sub Form_Load()
Set IE = New InternetExplorer
With IE
    .navigate "about:blank"
    .Visible = True
End With
End Sub

Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp is IE) Then
    Dim t As HTMLMetaElement, idx As Integer
    Dim hdoc As HTMLDocument
    Set hdoc = IE.document
    With List1
        .Clear
        For Each t In IE.document.All.tags("META")
            ReDim Preserve oMetaTags(idx)
            If t.Name = "" Then
                .AddItem "[None]"
            Else
                .AddItem t.Name
            End If
            Set oMetaTags(idx) = t
            idx = idx + 1
        Next
    End With
    If URL = "about:blank" Then
        sUrl = "about:blank"
    Else
        sUrl = IE.document.Title
    End If
End If
End Sub

Private Sub List1_Click()
With Text2
    .Text = ""
    .Text = oMetaTags(List1.ListIndex).content
End With
End Sub

Hope you have enjoyed that work as i did.
;)


©2001 - Richie Simonetti