Link to home
Start Free TrialLog in
Avatar of Sam80
Sam80

asked on

How ot use a script file to download a file ?

I want to download a file from the web
like http://www.abc.com/file.txt , use the script file.
but there seems no object support this function.
Avatar of aelatik
aelatik
Flag of Netherlands image

Avatar of Sam80
Sam80

ASKER

Thanks , aelatik .
The function is just what i want.
but in vb script ,I can not use the window api function,which force me had to find out an object that can attain this requirement.

I will be greatly appreciate to your new answer.
ASKER CERTIFIED SOLUTION
Avatar of emadat
emadat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This function will work from VBS. It relies on MS XML

However, It might need some modification in creating the object. Try the commented line if the first did not work

Function GetHTML(sURL As String) As String
Dim objXMLHTTP, xml
    Set xml = CreateObject("Microsoft.XMLHTTP")
'    Set xml = CreateObject("MSXML2.XMLHTTP")
    xml.Open "GET", sURL, False
    xml.send
    GetHTML = xml.responseText
    Set xml = Nothing
End Function

Good luck
If its just for text and other type of pages use :

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate "http://www.abc.com/file.txt"
    While IE.Busy
    Wend
       GetHTMLCode = IE.Document.documentelement.innerHTML
MsgBox GetHTMLCode
hearing...
Avatar of Sam80

ASKER

thanks , guys, excellent!!!

and now i want one more function is that save the file to the specific folder , how ?
Avatar of Sam80

ASKER

how about if my request file is not a text file ?
it might be any kind such as exe,jpg and so on.
Hi Sam80,
This old question (QID 20562465) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.