各位老师:
请教一个代码问题:我们的数据是网页上,后缀是.aspx,我想在网页上提取数据,保存在表A中,但就是提取不下来,代码如下:
DataTables("表A").DataRows.Clear()
Dim web As new System.Windows.Forms.WebBrowser
web.ScriptErrorsSuppressed = True
web.Navigate("http://。。。。.aspx")
Do Until web.ReadyState = 4
Application.DoEvents
Loop
Dim ss As String
For Each div As object In web.Document.GetElementsByTagName("div")
If div.GetAttribute("ClassName") = "stockcont" Then
Dim ps = div.GetElementsByTagName("p")
For Each tr As object In div.GetElementsByTagName("tr") ‘标红的在网页解析中找不到
Dim ths = tr.GetElementsByTagName("th")
If ths.Count > 0 Then
ss = ths(0).innerText
End If
Dim dr As Row= Tables("表A").AddNew()
dr("第五列") = ps(0).innerText
dr("第六列") = ps(1).innerText
dr("第七列") = ss
Dim tds = tr.GetElementsByTagName("td")
For i As Integer = 0 To tds.count - 1
dr("A" & i) = tds(i).innerText
Next
Next
End If
Next
网页解析见附件:
请各位老师费心,看看代码错在那里了,给改改!
谢谢!
[此贴子已经被作者于2020/11/26 23:35:47编辑过]