Im trying to get some specific data from a website my workplace uses, however, I cannot figure out on how to get that specific data. Here is a snippet of the code from the website:
<tr class="outboundPlanAltRowStyle">
<td class="outboundPlanHour" style="height:25px;width:40px;white-space:nowrap;">11:00</td>
<td onmouseover="this.className='outboundPlanHover'" onmouseout="this.className=''"
onclick="cellClicked(1019543,14)"
style="height:25px;width:150px;white-space:nowrap;" class="">
<table class="outboundPlan_PREBOOKED" style="width: 200px; table-layout: fixed" cellpadding="0px" cellspacing="0px">
<tbody><tr>
<td title="Purchase Order / Status" class="outboundCell"> 325839 / PREBOOKED</td></tr>
<tr><td title="Subcontractor Name / Load Numbers "
class="outboundCell">Tesco FM / - </td></tr>
<tr><td title="Planned Destinations " class="outboundCell"
style="overflow: hidden"> 39019 (NDC Teresin Tesco) </td></tr>
<tr><td title="Status Date" class="outboundCell">28.01.2021 12:02 </td></tr></tbody>
</table></td>
<td onmouseover="this.className='outboundPlanHover'" onmouseout="this.className=''"
onclick="cellClicked(1019544,14)"
style="height:25px;width:150px;white-space:nowrap;" class="">
<table class="outboundPlan_CONFIRMED" style="width: 200px; table-layout: fixed" cellpadding="0px" cellspacing="0px"><tbody>
<tr><td title="Purchase Order / Status" class="outboundCell"> 325676 / CONFIRMED</td>
<td title="Released" class="outboundCell3">R</td></tr>
<tr><td colspan="2" title="Subcontractor Name / Truck No / Trailer No " class="outboundCell">Tesco ESA / 4H5 5484 / 4H2 6597</td></tr>
<tr><td colspan="2" title="Load Numbers / Store Names" class="outboundCell"> 25060, 250601, 250602 / Ceska Trebova 3k, HM USTI NO 3k, HM VYSOKE MYTO</td></tr><tr><td title="Status Date" class="outboundCell">28.01.2021 22:29</td>
<td title="25060-31-B-HV" class="outboundCell2">32 DC2</td>
</tr></tbody></table></td><td style="height:25px;width:150px;white-space:nowrap;"><table class="outboundPlanOpen" style="width: 200px; table-layout: fixed" cellpadding="0px" cellspacing="0px"><tbody><tr><td> </td></tr>
<tr><td>(open)</td></tr>
<tr><td> </td></tr><tr><td> </td></tr></tbody></table></td><td style="height:25px;width:150px;white-space:nowrap;"><table class="outboundPlanOpen" style="width: 200px; table-layout: fixed" cellpadding="0px" cellspacing="0px"><tbody><tr><td> </td></tr>
<tr><td>(open)</td></tr>
<tr><td> </td></tr><tr><td> </td></tr></tbody></table></td><td style="height:25px;width:150px;white-space:nowrap;"><table class="outboundPlanOpen" style="width: 200px; table-layout: fixed" cellpadding="0px" cellspacing="0px"><tbody><tr><td> </td></tr>
<tr><td>(open)</td></tr>
<tr><td> </td></tr><tr><td> </td></tr></tbody></table></td><td style="height:25px;width:150px;white-space:nowrap;"><table class="outboundPlanOpen" style="width: 200px; table-layout: fixed" cellpadding="0px" cellspacing="0px"><tbody><tr><td> </td></tr>
<tr><td>(open)</td></tr>
<tr><td> </td></tr><tr><td> </td></tr></tbody></table></td>
</tr>
Im trying to get the value "39019 (NDC Teresin Tesco)" from the class="outboundCell"> 325839 / PREBOOKED< class into cell A1 on Sheet1, however, i cannot define it properly. Here is the code ive got so far:
Sub WebNavigate()
im objIE As Variant
Dim WebSite As Variant
Dim Element As Variant
Dim i As Variant
Set objIE = CreateObject("InternetExplorer.Application")
WebSite = "https://*******.aspx"
Sleep 1000
With objIE
.Visible = True
.Navigate WebSite
Do While .Busy Or .ReadyState <> 4
DoEvents
Loop
Sleep 1000
objIE.Document.all.Item("ctl00$Content$Login1$UserName").Value = "*****"
objIE.Document.all.Item("ctl00$Content$Login1$Password").Value = "*****"
Sleep 1000
objIE.Document.getElementsByName("ctl00$Content$Login1$LoginButton")(0).Click
Sleep 1000
End With
If objIE.ReadyState = 4 Then
objIE.Navigate "https://******"
End If
Sleep 1000
Do While objIE.Busy Or objIE.ReadyState <> 4
DoEvents
Loop
Sleep 1000
If objIE.ReadyState = 4 Then
Dim getTodayDay As Variant
getTodayDay = Day(Now) '- 1
objIE.Document.getElementsByClassName("CalendarDayNo")(getTodayDay).Click
End If
Sleep 1000
Do While objIE.Busy Or objIE.ReadyState <> 4
DoEvents
Loop
Sleep 1000
If objIE.ReadyState = 4 Then
Dim text As String
Dim Data As Variant
text = " 325839 / PREBOOKED"
Set Data =objIE.Document.getElementsByClassName("outboundCell")(text).
Sleep 1000
Do While objIE.Busy Or objIE.ReadyState <> 4
DoEvents
Loop
End If
End Sub
I intentionally left out the name of the site and login name and password. The snippet of code I worte successfully takes me to the relevant page, where the information is written, however, I just cant figure out on how to get it. That is why the Set Data =objIE.Document.getElementsByClassName("outboundCell")(text).
part isn't finished.
question from:
https://stackoverflow.com/questions/65946677/how-to-get-specific-value-with-getelementsbytagname-with-td-with-overflow-hid 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…