以下代码为原来的,之前能同时获取基础数据和图片数据,但是现在出现这个count问题,但是用以下代码分别获取基础数据或图片数据 有能正常获取,不知道问题出在那,楼上datacolchanged事件在执行以下代码时是没有触发的。
Dim txb1 As String = "http://ia.com/house/view?id=" & e.Form.Controls("TextBox5").text
Dim wz As String = "FYID"
Dim te As String = "tel"
Dim dr As Row = Tables("house").addnew
dr(wz) = txb1
dr(te) = e.Form.Controls("TextBox3").text
'获取基础数据
Dim txb As WinForm.TextBox = e.Form.Controls("TextBox6")
Dim web As new windows.forms.webbrowser
web.ScriptErrorsSuppressed = True
web.Navigate(txb.Text)
Do Until web.ReadyState = 4
Application.DoEvents
Loop
For Each dl As object In web.Document.GetElementsByTagName("DIV")
If dl.GetAttribute("classname") = "col-lg-10" Then
Dim dll = dl.Innertext
If dll > "" Then
Dim Parts() As String = dll.Split(vbcrlf)
dr("房源ID") = (Parts(0).Remove(0,5))
dr("房源编号") = (Parts(2).Remove(0,6))
'.......
End If
End If
Next
'获取图片数据
Dim idx = 1
For Each dl As object In web.Document.GetElementsByTagName("img")
Dim url = dl.GetAttribute("src")
If url > "" Then
Dim c As String = "图片" & idx
If Tables("house").Cols.Contains(c) Then
dr(c) = url
End If
idx += 1
End If
Next
web.Dispose()
GC.Collect()