Hi Guys,
i am trying to automate fetching data from a Internal website using VBA. i Have serial numbers in Col A and want to populate results in Col B respectively.
I have Below VBA code.
Sub datascrape()Dim IE As Object Dim Doc As HTMLDocument Dim foo As Object, myStr As String 'Set foo = objIE.Document.getElementsByClassName("Message")(0).getElementsByTagName("a")(0) Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True IE.navigate "URL" Do While IE.Busy Or IE.ReadyState <> 4 Application.Wait DateAdd("s", 1, Now) Loop Set Doc = IE.Document For rowNo = 1 To 5 Doc.getElementById("txtField1").Value = ThisWorkbook.Sheets("Sheet1").Range("A" & rowNo).Value Doc.getElementById("CtrlQuickSearch1_imgBtnSumbit").Click Do While IE.Busy Or IE.ReadyState <> 4 Application.Wait DateAdd("s", 1, Now) Loop strVal = Doc.getElementsByClassName("tlc_node_text")(0).innerText ThisWorkbook.Sheets("Sheet1").Range("B" & rowNo).Value = strVal Next End Subi want to fetch the value FOC1904U00Z in the last from "<span><a style="color: green;" href="rpUUT_HistoryData.aspx?SN=FOC1904U00Z">FOC1904U00Z</a></span>" element.HTML Code:<div class="tlc_node_text" style="left: 0px; width: 200px;"><span><img width="16" height="16" align="absmiddle" style="cursor: hand;" onclick="TreeListControlHandler.callCollapse(0,2);" onmouseenter="TreeListControlHandler.preventRowClick=true;" onmouseleave="TreeListControlHandler.preventRowClick=false;" src="images/handle.collapse.end.gif"><img width="16" height="16" align="absmiddle" src="images/pcbicon.jpg"></span> <span><a style="color: green;" href="rpUUT_HistoryData.aspx?SN=FOC1904U00Z">FOC1904U00Z</a></span></div>
i tried strVal = Doc.getElementsByClassName("tlc_node_text")(0).getElementsByTagName("a")(0) .innerText
but this is returnig VBA error.
can some one help me to resolve this?
Note-the website is Intranet and need credentials. hence not sharing website info.
Thanks in advance




Reply With Quote