Reference:
Excel VBA 2a:Learning MSXML2.XMLHTTP
Scraping a website's HTML in VBA
XmlHttp Post in Excel VBA not updating website form
Example:
use VBA to download 台灣期貨交易所的台股期貨
http://www.taifex.com.tw/chinese/3/3_1_2.asp
VBA code:
Sub get_taifex()
Dim pXmlHttp As Object
Set pXmlHttp = CreateObject("MSXML2.XMLHTTP")
pXmlHttp.Open "POST", "http://www.taifex.com.tw/chinese/3/3_1_2dl.asp", False
pXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
pXmlHttp.send ("goday=&DATA_DATE=&DATA_DATE1=&DATA_DATE_Y=&DATA_DATE_M=&DATA_DATE_D=&DATA_DATE_Y1=&DATA_DATE_M1=&DATA_DATE_D1=&syear=&smonth=&sday=&syear1=&smonth1=&sday1=&datestart=2016%2F09%2F14&dateend=2016%2F10%2F14&COMMODITY_ID=TX&commodity_id2t=&his_year=2015")
MsgBox pXmlHttp.ResponseText
End Sub
用 Wireshark 收集到的網頁傳輸參數
沒有留言:
張貼留言