
Retrieving and writing to File
Hi Joseph;
Getting a "object doesn't support this property or method..."
I was able to find some more info and looks like I need an ADODB.stream
object to capture the data. Also using MSXML2.XMLHTTP seems to be a better
choice than Microsoft.XMLHTTP.
I just need to grab a copy of a web page being served, and then parse that
page for error codes. The service and port on the server seem to be fine,
just need to be aware of error pages being served on an IIS5 box....(in case
you were wondering what the potential use of a script like this might be.)
Thanks for your suggestion Joseph.
My preliminary tests with this code worked...
Call HTTP_GET ("http://www.somewebsite.com", "website.txt")
Function HTTP_GET (SRC, DST)
Dim ASt
Dim oHttp
Dim FSO
Set oHttp = CreateObject ("MSXML2.XMLHTTP")
With oHttp
.Open "GET", SRC, False
.SetRequestHeader "range", "bytes=" &"-"
.Send
End With
Set ASt = CreateObject ("ADODB.Stream")
With ASt
.Type = 1
.Open
Set FSO = CreateObject ("Scripting.FileSystemObject")
If FSO.FileExists (DST) Then
.LoadFromFile DST
FSO.DeleteFile DST
Set FSO = Nothing
End If
.Position = .Size
.Write oHttp.ResponseBody
.SaveToFile DST
End With
Set ASt = Nothing
Set oHttp = Nothing
End Function
Quote:
> No sooner posted then I see a typo. Try:
> OutputFile.Write xml.responseText
> I think the ( ) are causing the problem
> Joe
> > Try
> > outputfile.write xml.response.txt
> > I think the ( ) are causing the problem
> > Joe
> > > Hi There;
> > > I need a little help figuring this one out. I'm running this script
by
> > > invoking wscript.exe not through ASP like most examples give...
> > > Set xml = CreateObject("Microsoft.XMLHTTP")
> > > xml.Open "GET", "http://www.somewebsite.com/default.asp", False
> > > xml.Send
> > > Set fso = CreateObject("Scripting.FileSystemObject")
> > > Set OutputFile = fso.CreateTextFile("website.html", True)
> > > OutputFile.write(xml.responseText)
> > > OutputFile.Close
> > > When I run this code I get an "Invalid Procedure call or argument"
> error.
> > > 800A0005.
> > > If I change the OutputFile.Write(xml.responseText) to WScript.Echo
> > > (xml.responseText) I can get a message box of the value that I want to
> > write
> > > to file.
> > > Please help me...going crazy trying to figure this one out.
> > > thanx