#2
ls_y0413 小时前
|
Sub query()
Dim i&, r&, n&, k&
Dim postData$, proCode$, proName$, firstClass$, secondClass$
Dim arr()
Dim oDom As Object, oWindow As Object, http As Object
Set oDom = CreateObject("htmlfile")
Set oWindow = oDom.parentWindow
Set http = CreateObject("Msxml2.XMLHTTP")
r = [A65536].End(xlUp).Row
If r > 2 Then Range("A2:H" & r).ClearContents
proCode = [J5]: proName = [J6]: firstClass = [J3]: secondClass = [J4]
postData = "{" & Chr(34) & "Context" & Chr(34) & ":{" & Chr(34) & "argv" & Chr(34) & ":{" & Chr(34) & "proCode" & Chr(34) & ":" & Chr(34) & proCode & Chr(34) & "," & Chr(34) & "proName" & Chr(34) & ":" & Chr(34) & proName & Chr(34) & "," & Chr(34) & "firstClass" & Chr(34) & ":" & Chr(34) & firstClass & Chr(34) & "," & Chr(34) & "secondClass" & Chr(34) & ":" & Chr(34) & secondClass & Chr(34) & "}}}"
http.Open "POST", "https://www., False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "AirScript-Token", "2jhQZq9WdAtvCUVFlxm8wl"
http.send (postData)
strHtml = http.responseText
oWindow.execScript "js=" & strHtml
n = oWindow.eval("js.data.result.length")
If n = 0 Then
MsgBox "没有可下载的数据"
Exit Sub
End If
ReDim arr(0 To n - 1, 0 To 6)
For i = 0 To n - 1
For k = 0 To 6
arr(i, k) = oWindow.eval("js.data.result[" & i & "][" & k & "]")
Next
Next
[A3].Resize(n, 7) = arr
MsgBox "完成"
End Sub