标签:
Sub utilDownloadFile(strFilePath, strURL) Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1") ‘WinHttpReq.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "xxx.xxx.xxx.xxx:zzzz" ‘Required only if your internet routes through a proxy. Not required in 90% cases. ‘You can ignore this line for first attempt but add it if your download is hindered, X is IP and Z is Port temp = WinHttpReq.Open("POST", strURL, false) ‘WinHttpReq.SetCredentials "Username", "Password", HTTPREQUEST_SETCREDENTIALS_FOR_SERVER ‘Required only if the file download server required authentication. Not required in 90% cases. Change Username and Password wuth actuals. WinHttpReq.Send() WinHttpReq.WaitForResponse strResult = WinHttpReq.ResponseBody Set oStream = createobject("Adodb.Stream") Const adTypeBinary = 1 Const adSaveCreateOverWrite = 2 oStream.type = adTypeBinary oStream.open oStream.write strResult oStream.savetofile strFilePath, adSaveCreateOverWrite End Sub
标签:
原文地址:http://www.cnblogs.com/ellie-test/p/4518998.html