Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automate file download from website 1

Status
Not open for further replies.

mrmovie

Technical User
Oct 2, 2002
3,094
GB
Hi all,
I need to script something to go to a web site and download some files. if i know where the files are located what would you suggest is the best way to get the files on the local machine?
also, in order to determine which files i need to download there would need to be some logic involved. this logic would stem from reading a '2download.ini' file lets say, so the client would need to read the contents of 2download.ini to determine which files it would need to download. i hope i am making sense.
i guess what i am going to try and make is some sort of custom, 'check for updates' process.
what i am wondering is

1. the best way to script the download of files from website
2. the best way to read a file on a website, i guess this could be covered in point one, then just open it locally?

Thanks
von moyla
 
You may consider the native windows ftp.exe with the -s option.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
please excuse my ignorance but with ftp work if the server isnt an ftp box? or am i being silly?
 
Sorry, I didn't realize you talked about pure http download.
 
no worries, the target is something like


if i put this in my browser i get the file download prompt. i was hoping i could use something to grab it automatically. i think ("MSXML2.XMLhttp") might be something i need to look at
 
I use something like the following to download files from a secure site. Although since we changed the site to use Siteminder I am unable to access the files this way anymore. For non-secure sites just delete the userid and pass from the end of the GET line.

Dim xmlHTTP : Set xmlHTTP = CreateObject("Microsoft.XMLHTTP")
Dim adoStream : Set adoStream = CreateObject("adodb.stream")

Const bGetAsAsync = False ' wait for response
Const adTypeBinary = 1 ' ado typelib constants
Const adModeReadWrite = 3
Const adSaveCreateOverwrite = 2
Const ForReading = 1, ForWriting = 2, ForAppending = 8

sSource = "sSaveName = "savename.exe"
sSavePath = "C:\test\"

xmlHTTP.Open "GET", sSource, bGetAsAsync, "userid", "pass"
xmlHTTP.Send
'
With adoStream ' write the file to local disk
.Type = adTypeBinary ' as BINARY
.Mode = adModeReadWrite
.Open
.Write xmlHTTP.responseBody ' write data (as binary)
.SaveToFile sSavePath & sSaveName, adSaveCreateOverwrite
.Close
End With
 
thanks for the reply Coremirror, i ended up with a similar solution, should have posted the solution but there go, thanks for the effort though
 
Your welcome, have you ever tried to do this on a forms authentication protected by siteminder secured site?(Siteminder uses cookies) I was able to login using send keys but would really like it to be able to do it more seamlessly.
 
sorry, i dont think that applied to me,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top