How to Get and Post data in VBScript

VBS,VBScript get url,VBScript post url,vbs get page,vbs post page

VBScript Get URL

How to Get and Post data in VBScript



VBScript

Example:

msgbox URLget("http://www.live.uk.net/")
msgbox IEGetPage("http://www.live.uk.net/")



Function URLGet(URL)
' Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
' Set Http = CreateObject("WinHttp.WinHttpRequest.5")
' Set Http = CreateObject("WinHttp.WinHttpRequest")
' Set Http = CreateObject("MSXML2.ServerXMLHTTP")
' Set Http = CreateObject("MSXML2.XMLHTTP")
Set Http = CreateObject("Microsoft.XMLHTTP")
Http.Open "GET",URL,True
Http.Send
pagestatus = Http.status
if pagestatus<>"200" then
URLGet="Error:"& pagestatus
else
' URLGet = Http.ResponseBody
URLGet = Http.responseText
end if
End Function

Function URLPost(URL,FormData,Boundary)
Set Http = CreateObject("Microsoft.XMLHTTP")
Http.Open "POST",URL,True
' Http.setRequestHeader "Content-Type","multipart/form-data; boundary="& Boundary
Http.send FormData
for n = 1 to 9
If Http.readyState = 4 then exit for
' Http.waitForResponse 1
b = shell.popup("Getting page",1,"Message")
next
If Http.readyState <> 4 then
URLPost = "Failed"
else
URLPost = Http.responseText
end if
End Function



Function IEGetPage(URL)
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate URL
Do While IE.Busy
Wait 1, "Waiting response from"& URL
Loop
IEGetPage = IE.Document.Body.innerHTML
IE.Stop
IE.Quit
End Function

Function IEPostBinaryRequest(URL,FormData,Boundary)
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate URL, , , FormData,"Content-Type: multipart/form-data; boundary="+ Boundary + vbCrLf
Do While IE.Busy
Wait 1, "Upload To "& URL
Loop
IEPostBinaryRequest = IE.Document.Body.innerHTML
IE.Stop
IE.Quit
End Function



' convert binary to strings
Function ChrB(data)
a = ""
For n = 1 To LenB(Binary)
a = a & Chr(AscB(MidB(data,n,1)))
Next
ChrB = a
End Function



Keywords: VBS,VBScript get url,VBScript post url,vbs get page,vbs post page