By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,394 Members | 1,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,394 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"paul fpvt2" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
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.
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.