Thanks Richard,
I found this
StackOverflow page.
Using the Download method and your suggestion, able to get the desired outcome.
Download( UrlToFile, SaveFileAs:="", Overwrite := True, headers := "", method := "GET", postData := "")
{
MsgBox, %headers%
WinHttpObj := ComObjCreate( "WinHttp.WinHttpRequest.5.1" )
WinHttpObj.Open( method, UrlToFile )
For header, value in headers
WinHttpObj.SetRequestHeader( header, value )
WinHttpObj.Send( postData )
ADODBObj := ComObjCreate( "ADODB.Stream" )
ADODBObj.Type := 1
ADODBObj.Open()
ADODBObj.Write( WinHttpObj.ResponseBody )
If !SaveFileAs
{
urlSplitArray := StrSplit( UrlToFile, "/" )
SaveFileAs := urlSplitArray[ urlSplitArray.MaxIndex() ]
}
ADODBObj.SaveToFile( SaveFileAs, Overwrite ? 2:1 )
ADODBObj.Close()
}
customHeaders := { "User-Agent": "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
,"Content-Type": "application / zip, application / octet - stream""application / zip, application / octet - stream"
,"Accept-Encoding": "gzip,deflate,sdch"
,"Referer": "https://www.nseindia.com/products/content/equities/equities/archieve_eq.htm"
,"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" }
Download( "https://www.nseindia.com/content/historical/EQUITIES/2015/DEC/cm31DEC2015bhav.csv.zip", "C:\Users\Dave\Desktop\Happy.zip", True, customHeaders )