我正在尝试从ASP.NET maker创建的网页中提取数据。
该页面基本上是一张大桌子。
当我对表格进行更改时,更改将显示在页面和html代码中。当我将网页导出到Excel工作表时,更改也会出现。但是,当我使用inttertext方法抓取网页时,更改不会出现。
Dim htmlTable As MSHTML.IHTMLElement
Dim htmltables As MSHTML.IHTMLElementCollection
Dim htmlRow As MSHTML.IHTMLElement
Dim htmlcell As MSHTML.IHTMLElement
Dim rowNum As Long, colNum As Integer
Dim x As Integer
Dim y As Integer
'Note: htmltable(s) is collection of elements not a single element.
Set htmltables = htmlPage.getElementsByTagName("table")
For Each htmlTable In htmltables
'Debug.Print htmlTable.className
x = 1
For Each htmlRow In htmlTable.getElementsByTagName("tr")
'Debug.Print vbTab & htmlRow.innertext
y = 1
'//This prints out any level below the "tr" element
For Each htmlcell In htmlRow.Children
'Debug.Print vbTab & htmlcell.innertext
Sheet3.Activate
Cells(x, y) = htmlcell.innertext
y = y + 1
Next htmlcell
x = x + 1
Next htmlRow
Next htmlTable
每个人以前都有过类似经历吗?我不知道出了什么问题。