How can I copy an html file to a local drive ?

M

McKirahan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top