excel VBA快递查询
用Excel查询快递:
'参数名称 类型 是否必需 描述
'key string 是 授权密钥,点击此处 [
http://www.aikuaidi.cn/api/?type=1 ] 即可申请
'order string 是 快递单号,请注意区分大小写
'id string 是 快递代号,如:圆通(yuantong)、申通(shentong), 查看完整快递代号(http://www.aikuaidi.cn/api/?type=2)
'ord string 可选 排序规则:asc:按时间旧到新排序,desc:按时间新到旧排序,不传默认值: asc
'show string 可选 返回类型:json:返回json字符串,xml:返回xml字符串,html:返回html字符串,不传默认值: json
Private Sub CommandButton1_Click() '快递API On Error Resume Next Dim arr() bt = Split("id,name,order,num,updateTime,message,errCode,status,data", ",") With CreateObject("WinHttp.WinHttpRequest.5.1") .Open "GET", "http://www.aikuaidi.cn/rest/?key=89b03a78eaa8bb1187a9909eee85c714a&order=205075369291&id=shunfeng&ord=asc&show=json", False .send tt = "brr=" & .responsetext ss = Split(tt, "},{") With CreateObject("MSScriptControl.ScriptControl") .Language = "JScript" .AddCode tt For i = 0 To UBound(bt) - 1 Cells(1, i + 1) = .Eval("brr." & bt(i)) Next i For i = 0 To UBound(ss) + 1 Cells(1, UBound(bt) + i * 2 + 1) = .Eval("brr.data[" & i & "].time") Cells(1, UBound(bt) + i * 2 + 2) = .Eval("brr.data[" & i & "].content") Next i End With End With End Sub
原文出处:http://blog.csdn.net/a814153a/article/details/9061917