求助用VBA抓取网页数据(求版主帮助~~)
本人初学VBA,需要在http://www.sse.com.cn/disclosure/diclosure/etf/index.shtml?type=8&etfClass=2这个网站上抓取表格里面的数据,但是它的源文件中显示不出表格的数据,这样应该怎么读取呢?很紧急,望版主和各位大神帮助。。 网页抓取
[解决办法]
Excel Vba:
Sub 成份股信息内容()
On Error Resume Next
Cells.Clear
Cells.NumberFormatLocal = "@"
Set ms = CreateObject("MSScriptControl.ScriptControl")
ms.Language = "javascript"
ar = Split("instrumentId,instrumentName,quantity,substituteFlag,premiumRate,cashAmount", ",")
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", "http://query.sse.com.cn/infodisplay/queryConstituentStockInfo.do?jsonCallBack=a&isPagination=false&type=8&market=&etfClass=2&_=" & ms.Eval("new Date().getTime()"), False
.SetRequestHeader "Referer", "http://www.sse.com.cn/disclosure/diclosure/etf/index.shtml?type=8&etfClass=2"
.SetRequestHeader "Connection", "Keep-Alive"
.Send
ms.AddCode Replace(Replace(.responseText, "(", "="), ")", "")
yema = ms.Eval("a.result.length")
For i = 0 To yema
For j = 0 To 5
Cells(i + 1, j + 1) = ms.Eval("a.result[" & i & "]." & ar(j))
Next
Next
End With
End Sub