|
本帖最后由 俊锋伍贰零 于 2015-10-27 05:34 编辑
json数据处理不会弄了,请高手们点拨一下,谢谢。
Sub test()
Dim winhttp, URL, arr2(), i, p, t1, t2, k, pages, arr1, d, code
Dim aa, x, y As Object, s, Cell, j, ar, liebiao, n
Dim arr(1 To 158, 1 To 33)
Sheet1.Cells.Clear '清除内容
Set winhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
With winhttp
URL = "http://fundata.jnlc.com/SitePages/Layouts/JNPJFeature/search.ashx?qt=FundPrice&iFundID=0&strTailIndex=0&strTermType=0&t=2015-10-23&strActStyle=0&strInvestType=0&begindate=2015-10-23&enddate=2015-10-23&shareType=&strIfAOn=%E6%98%AF&strInvestCode=×tamp=1445855402095&_search=false&nd=1445855402106&rows=30&page=1&sidx=dPriceIncrease&sord=desc "
.Open "GET", URL, False
.setRequestHeader "Connection", "Keep-Alive"
.send
t = .responsetext
With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") '调试用,数据放入剪贴板
.SetText t
.PutInClipboard
End With
'Debug.Print t
'Stop
With x
Set x = CreateObject("ScriptControl")
x.Language = "JScript"
s = "function getjson(s) { return eval('(' + s + ')'); }"
x.addcode s
Set y = x.codeobject.getjson(t)
Debug.Print y
'Stop
For Each p In CallByName(CallByName(y, "rows", VbGet), "cell", VbGet) ‘不会弄了
n = n + 1
arr1 = Split(p, ",")
Cells(n, 1).Resize(1, UBound(arr) + 1) = arr
Next
End With
End With
Set winhttp = Nothing
Set arr1 = Nothing
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
--------------------------------------------------------------------------
到了这就不会弄了,期待高手点拨一下。O(∩_∩)O谢谢!
|
|