Vba Code To Click On Excel Icon From A Webpage - Part 2
Following on the post Click on Excel Icon to download data Part1 There is another Excel icon to download historical stock price in the following link Historical Stock Data that I w
Solution 1:
Adapting from SIM's answer, you only need to change the URL
and params
variable as below:
Sub DownloadExcel()
Const URL$ = "http://finance.tvsi.com.vn/Data/LichsugiaExel?"
Dim aBody As Variant, sPath$, params$
params = "symbol=AAA&duration=d&startDate=25/07/2020&endDate=25/07/2021"
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL & params, False
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36"
.send
aBody = .responseBody
sPath = ThisWorkbook.Path & "\" & "output.xls"
EndWithWith CreateObject("ADODB.Stream")
.Type =1
.Open
.write aBody
.SaveToFile sPath, 2
.CloseEndWithEnd Sub
In the Devtools, look for the network traffic under Network Tab and click the Excel icon while Devtools is open, you should see a request that returns a document, the Request URL is what you need.
Post a Comment for "Vba Code To Click On Excel Icon From A Webpage - Part 2"