epactheactor
New Member
- Joined
- Sep 9, 2015
- Messages
- 38
Hello! I am trying to build a simple macro for a friend to make his life easier. It is to go to a web site and pull data from a certain section which will be pasted in Excel. I thought it would be a simple getElementByID or Class Name like I've done before, but I have not had any luck. Would love any suggestions or helpful hints. I'm putting a snippet of the HTML I'm trying to pull from below, where the sections that scream "I NEED THIS SECTION" are what I'm after. At first I tried to pull from ID "PIr11" but that gave me table header information. Then I tried by class name of "ssTableHeader" but got the same result. Also put a snippet of the VBA that I'm using way at the bottom. Thank you.
[/CODE]
[/CODE]
HTML:
<th class="ssTableHeaderLabel">Location:</th><td style="padding-left:10px"><b>Big Time</b></td></tr><tr><th class="ssTableHeaderLabel">Officer:</th><td style="padding-left:10px"><b>Doe, John</b></td></tr></table></td></tr></table></td></tr></table><table cellpadding="0" cellspacing="0" width="100%" border="0" style="table-layout: fixed" <col width="10%" /><col width="30%" /><col width="10%" /><col width="30%" /><col width="20%" /><caption><div class="ssDetailSectionTitle">Gen Information</div></caption><tr><td colspan="4"></td><th class="ssTableHeader" id="PIc5">Leader</th></tr><tr><th class="ssTableHeader" valign="top" rowspan="2" id="PIr01">Blocker</th><th class="ssTableHeader" valign="top" id="PIr11">Jane, Doe</th><td rowspan="2"></td><td rowspan="2" valign="top" headers="
 PIr01 
 PIr11">Dancer<br />
DOB: 1/1/1911<br />Good Dancer</td><td rowspan="2" valign="top" headers="
 PIr01 
 PIr11 
 PIc5
 "></td></tr><tr><td valign="top" headers="
 PIr01 
 PIr11"> 4327 AVE R <br /> HOUSTON, TX 77777<br /></td></tr><tr height="25"><td colspan="5"> </td></tr><tr><th class="ssTableHeader" valign="top" rowspan="2" id="PIr02">State</th><th class="ssTableHeader" valign="top" id="PIr12">The State</th><td rowspan="2"></td><td rowspan="2" valign="top" headers="
 PIr02 
 PIr12"> </td><td rowspan="2" valign="top" headers="
 PIr02 
 PIr12 
 PIc5
 "></td></tr><tr><td valign="top" headers="
 PIr02 
 PIr12"> I NEED THIS SECTION<br /> I NEED THIS SECTION<br /></td></tr></table>
VBA Code:
[CODE=vba]
[CODE=vba]URLa = Range("A3").Hyperlinks(1).Address
browser.navigate (URLa)
Set page = browser.document
Set otherElement = page.getElementsByClassName("ssTableHeader")
x = 1
num = 1
For Each ele In otherElement
Cells(x, 10).Value = otherElement.Item(num).innerText
x = x + 1
num = num + 1
Next
[/CODE]