Retrieving and writing to File 
Author Message
 Retrieving and writing to File

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.*-*-*.com/ ;, 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



Tue, 06 Dec 2005 07:13:42 GMT  
 Retrieving and writing to File
Try

outputfile.write xml.response.txt

I think the ( ) are causing the problem

Joe


Quote:
> 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



Tue, 06 Dec 2005 08:50:46 GMT  
 Retrieving and writing to File
No sooner posted then I see a typo.  Try:

OutputFile.Write xml.responseText

I think the ( ) are causing the problem

Joe


Quote:
> 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



Tue, 06 Dec 2005 08:53:53 GMT  
 Retrieving and writing to File

Quote:
> 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.

Google Groups: View Thread "retrieving text files"
http://groups.google.com/groups?th=91752f3d7c23efd3

The thread was in the context of fetching txt files via http, but it applies
to any responseText returned by xmlhttp...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft? Windows?2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Tue, 06 Dec 2005 09:27:31 GMT  
 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



Wed, 07 Dec 2005 03:05:26 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Writing & Retrieving Data from a file

2. Writing & Retrieving Info from file

3. Sample Text file - Retrieve data elements and write to SQL Server DB

4. retrieving a bitmap from memory to write out as a file

5. Writing a VBS file which reads and writes to the registry

6. How to get dbgrid to write / retrieve changes from a database

7. Cancelling file writing process during long writes

8. How to get dbgrid to write / retrieve changes from a database

9. Writing Templates from Webclass doesn't write entire htm file

10. Writing comma delimited text files using double quotes - Write Statement

11. How to retrieve File Summary from OLE Program's files

12. Storing and Retrieving a Binary file from a .res file

 

 
Powered by phpBB® Forum Software