此主题相关图片如下:网页问题1.png
要抓取“http://data.10jqka.com.cn/market/longhu/”网页数据,代码如下:
DataTables("表A").DataRows.Clear()
Dim web As new System.Windows.Forms.WebBrowser
web.ScriptErrorsSuppressed = True
web.Navigate("http://data.10jqka.com.cn/market/longhu/")
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
问题是:现在仅能抓取最后一次更新的数据,能否用代码改变网页“日期选择框”的日期选择抓取历史数据。