VBS脚本发送Http请求(Get,Post)
发送Get请求
发送Post请求:(包括json格式的内容)
Function sendHttpPost(posturl,params) Dim http Set http = CreateObject("MSXML2.ServerXMLHTTP") http.Open "POST",posturl,False,"","" http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" http.Send(params) If http.Status = "200" Then sendHttpPost = http.responseText Else sendHttpPost = http.Status & "<br />" & http.responseText End If Set http = nothing End Function ' 发送json内容 Function sendHttpPost2(posturl,params) Dim http Set http = CreateObject("MSXML2.ServerXMLHTTP") http.Open "POST",posturl,False,"","" http.setRequestHeader "Content-Type", "application/json" http.Send(params) If http.Status = "200" Then sendHttpPost2 = http.responseText Else sendHttpPost2 = http.Status & "<br />" & http.responseText End If Set http = nothing End Function ' 使用 ' ret = sendHttpPost("http://127.0.0.1:9090/", "{hello=123}") ' ret = sendHttpPost("http://localhost:8080/test03","id=231&name=Wee") ret = sendHttpPost2("http://localhost:9999/user/login","{""username"":""admin"",""password"":""123456""}") MsgBox ret
**
常记溪亭日暮,沉醉不知归路。兴尽晚回舟,误入藕花深处。争渡,争渡,惊起一滩鸥鹭。
昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否?知否?应是绿肥红瘦。