|
学习老师的代码,谢谢老师!
- Sub js()
- Dim arr(1 To 100, 1 To 5)
- sURL = "http://comment.10jqka.com.cn/tzrl/getTzrlData.php?callback=callback_dt&type=data&date=201608"
- Set oDom = CreateObject("HTMLFILE")
- Set oWindow = oDom.parentWindow
- Set oHTML = CreateObject("MSXML2.XMLHTTP")
- oHTML.Open "GET", sURL, False
- oHTML.send
- oWindow.execScript oHTML.responseText & ";function callback_dt(o){oj=o};n=oj.data.length"
-
- r = 0
-
- For i = 0 To oWindow.n - 1
- dt = oWindow.eval("var oi=oj.data[" & i & "]; oi.date+oi.week")
- m = oWindow.eval("oi.events.length")
- r = r + 1: arr(r, 1) = dt
- For j = 0 To m - 1
- arr(r, 2) = oWindow.eval("oi.events[" & j & "][0]")
- For Each u In Array("field", "concept")
- arr(r, 3) = arr(r, 3) & "," & oWindow.eval("ar=[];k=oi." & u & "[" & j & "];for(x in k){ar.push(k[x].name);ar}")
- Next
- arr(r, 3) = Trim(Replace(arr(r, 3), ",", " "))
- arr(r, 4) = oWindow.eval("ar=[];k=oi.stocks[" & j & "];for(x in k){ar.push(k[x].name);ar}")
- arr(r, 4) = Replace(arr(r, 4), ",", " ")
- r = r + 1
- Next
- r = r - 1
- Next
- Range("a2").Resize(r, 4) = arr
- End Sub
复制代码 |
|