This website has been down since the eveniong of the 23rd. it finally came
back up this morning.
I first look at the webpage using the Internet Explorer at use the menu
option VIEW - SOURCE which shows the source code in Notepad. The TAG items
start with a forward slash and ends with a 2nd forward slash ((may include
tag name
/abc ................ /
or
/abc ................ abc/
Tags can be nested and the slashes are always in pairs (an opening and
closing tag)
To get all the TAG info I usally use the code for SHEET1 below to get the
information.
You can get a trag name like in my example below for SHEET2
set MyTags = IE.document.getelementsbytagname("*")
or
set MyTags = IE.document.getelementsbytagname("abc")
You can also get classes which are shown in the source code as
name="top"></a><div id="msviMasthead"><table cellpadding="0"
The class name starts with id=
Which in this case is msviMasthead
Use this code to get the class
Set Class = IE.document.getElementById("msviMasthead")
See my code for SHEET3 below.
Sub test()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "
http://www.nissanusa.com/apps/dealerlocator"
Request = "?zipCode=07508&tool=Home.Locator"
'get web page
IE.Navigate2 URL & Request
Do While IE.readyState <> 4
DoEvents
Loop
With Sheets("Sheet1")
RowCount1 = 1
For Each itm In IE.document.all
.Range("A" & RowCount1) = itm.tagname
.Range("B" & RowCount1) = itm.ClassName
.Range("C" & RowCount1) = Left(itm.innertext, 1024)
RowCount1 = RowCount1 + 1
Next itm
End With
With Sheets("Sheet2")
RowCount2 = 1
For Each itm In IE.document.getelementsbytagname("*")
.Range("A" & RowCount2) = itm.tagname
.Range("B" & RowCount2) = itm.ClassName
.Range("C" & RowCount2) = Left(itm.innertext, 1024)
RowCount2 = RowCount2 + 1
Next itm
End With
With Sheets("Sheet3")
RowCount3 = 1
For RowCount = 1 To RowCount1 - 1
ClassName = Sheets("Sheet1").Range("B" & RowCount)
If ClassName <> "" Then
Set Class = IE.document.getElementById(ClassName)
If Not Class Is Nothing Then
.Range("A" & RowCount3) = Class.tagname
.Range("B" & RowCount3) = Class.ClassName
.Range("C" & RowCount3) = Left(Class.innertext, 1024)
RowCount3 = RowCount3 + 1
End If
End If
Next RowCount
End With
End Sub