示例代码:
- Sub Readjson()
- Dim http
- Dim aa as String
- Set http = CreateObject("Microsoft.XMLHTTP")
- http.Open "POST", "http://api.xxxx.com", False
- http.send ""
- If http.Status = 200 Then
- aa = http.responseText
- MsgBox "成功。"
- Else
- MsgBox "调用失败,错误代码:" & http.Status
- Range("A1").value = aa
- End If
- End sub
XMLHTTP是一个微软内置方法,可以直接获取API数据。文章源自原紫番博客-https://www.yuanzifan.com/53505.html
这里Http是一个定义的变量,是一个对象。文章源自原紫番博客-https://www.yuanzifan.com/53505.html
该对象的 .responseText方法,是直接返回Json字符串的文章源自原紫番博客-https://www.yuanzifan.com/53505.html
将字符串赋值给变量aa,再把aa写进A1单元格。需要进一步处理,则在AA之中用Js处理Json字符串。文章源自原紫番博客-https://www.yuanzifan.com/53505.html
文章源自原紫番博客-https://www.yuanzifan.com/53505.html
文章源自原紫番博客-https://www.yuanzifan.com/53505.html
站长微信
扫码添加(注明来意)

Yuanzifan99
原梓番博客公众号
博客内容精选

原梓番博客
评论