Hi guys,
I'm hoping that you could help me with my problem. I had a working script that download file from a website, however the needs changes that the file should be check everyday for new update and download and save all the file in a specific location. My problem is how to loop into a website and see if there is new update to download or not. I am only downloading two files which is zip file and very rare a pdf file. The zip file has a unique ID that increment by 1 if updated, example the file name is I001.zip, the update file will be I002.zip and so on. So basically I want to loop at the site and see if there are new files for the day and download it if any. Below is the previous code I am using.
I'm hoping that you could help me with my problem. I had a working script that download file from a website, however the needs changes that the file should be check everyday for new update and download and save all the file in a specific location. My problem is how to loop into a website and see if there is new update to download or not. I am only downloading two files which is zip file and very rare a pdf file. The zip file has a unique ID that increment by 1 if updated, example the file name is I001.zip, the update file will be I002.zip and so on. So basically I want to loop at the site and see if there are new files for the day and download it if any. Below is the previous code I am using.
Code:
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 = "website"
sSaveName = "same name as the file in download"
sSavePath = "location/path"
xmlHTTP.Open "GET", sSource, bGetAsAsync, "user", "password"
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