paul fpvt2 said:
How can I copy an html file to a local drive ?
For example: I would like to copy
www.mywebsite.mypage.htm to
c:\inetput\wwwroot\mydir\mypage.htm, can I do that ?
Thanks.
Try this.
Option Explicit
'*
Const cURL = "
www.mywebsite.mypage.htm"
Const cOUT = "c:\inetput\wwwroot\mydir\mypage.htm"
'*
WScript.Echo "Success? " & Fetch(cURL,cOUT)
Function Fetch(xURL,xOUT)
On Error Resume Next
Fetch = False
Err.Clear
Dim objXML
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET",xURL,False
objXML.Send
Dim strXML
strXML = objXML.ResponseBody
If Err.Number <> 0 _
Or objXML.Status <> 200 Then
Exit Function
End If
Set objXML = Nothing
Dim objADO
Set objADO = CreateObject("ADODB.Stream")
objADO.Type = 1
objADO.Open
objADO.Write strXML
objADO.SaveToFile xOUT,2
Set objADO = Nothing
Fetch = Err.Number = 0
End Function
It will work with binary files (e.g. images) as well.