Here are a couple of functions using two different methods that you can use to POST data to a web page or XML document and retrieve data using a GET operation.
The XMLHTTP object is extremely powerful and can be used to parse XML documents as well as GET and POST data. For more info please see:
http://msdn.microsoft.com/library/en-us ... mscXML.asp
VBSTART
Function HTTPPost(sUrl, sRequest)
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "POST", sUrl,false
oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHTTP.setRequestHeader "Content-Length", Len(sRequest)
oHTTP.send sRequest
HTTPPost = oHTTP.responseText
End Function
Function HTTPGet(URL)
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate URL
do while IE.Busy
loop
HTTPGet = IE.document.documentelement.outerhtml
IE.quit
Set IE = Nothing
End Function
VBEND
VBEval>HTTPGet("http://www.mjtnet.com/contact.htm"),HTMLResult
VBEval>HTTPPost("http://www.mjtnet.com/contact.htm","sen ... eplace.com"),HTMLResult2
HTTP GET and POST using VBscript
Moderators: Dorian (MJT support), JRL, Phil Pendlebury
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact: