2017-06-19 90 views
0

我試圖提取<td>6/19/2017 9:49:14 AM</td>中的日期。 <td>Time extracted</td> allways在同一行OddRow.getElementsByTagName("td")(*).innerText每次都能正常工作嗎?VBA:從HTML表中提取日期戳

enter image description here

+0

不知道它的父對象,我不能說。我懷疑它是第二個OddRow。 –

+0

@Nathan_Sav你認爲建立一個包含所有'​​'標籤和'instr'搜索日期的數組是很好的嗎? – Quint

回答

0

這樣的事情,我相信。

Sub Scrape_HTML() 

Set ie = CreateObject("InternetExplorer.application") 

With ie 
    .Visible = True 
    .navigate "your_URL_here" 

' Wait for the page to fully load; you can't do anything if the page is not fully loaded 
Do While .Busy Or _ 
    .readyState <> 4 
    DoEvents 
Loop 

         Set Links = ie.document.getElementsByTagName("td") 
         RowCount = 1 

          ' Scrape out the innertext of each 'td' element. 
          With Sheets("DataSheet") 
           For Each lnk In Links 
            .Range("A" & RowCount) = lnk.innerText 
            RowCount = RowCount + 1 
           Next 
          End With 

End Sub