G
Guest
I have a VBScript as follows:
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 = "https://website.com/download/companyname.20060101.zip"
sSaveName = "companyname.20060101.zip"
sSavePath = "C:\temp\dir\"
xmlHTTP.Open "GET", sSource, bGetAsAsync, "username", "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
This is great when specifying an individual file, but I need to grab the
last modified file each morning. The file will take on the format of
companyname.20060101.zip Do I need a GET statement or something?
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 = "https://website.com/download/companyname.20060101.zip"
sSaveName = "companyname.20060101.zip"
sSavePath = "C:\temp\dir\"
xmlHTTP.Open "GET", sSource, bGetAsAsync, "username", "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
This is great when specifying an individual file, but I need to grab the
last modified file each morning. The file will take on the format of
companyname.20060101.zip Do I need a GET statement or something?