来源:http://www.minioa.net/office/viewtopic.php?f=3&t=99
Excel中如何读取一个网页你可以在单元格中使用,比如A2=Stock(A1),其中A1未股票代码,上证后加1,深证后加2,共7位,详情看东方财富网。例如6018181,0000392
Function Stock(cell)
Dim str
Dim arr
Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
Call objHttp.Open("GET", "http://hqdigi2.eastmoney.com/EM_Quote2010NumericApplication/CompatiblePage.aspx?Type=ZT&jsName=js_fav&fav=" & cell, False)
Call objHttp.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)")
Call objHttp.send("")
str = objHttp.ResponseText
arr = Split(str, ",")
Stock = arr(3)
End Function
Dim str
Dim arr
Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
Call objHttp.Open("GET", "http://hqdigi2.eastmoney.com/EM_Quote2010NumericApplication/CompatiblePage.aspx?Type=ZT&jsName=js_fav&fav=" & cell, False)
Call objHttp.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)")
Call objHttp.send("")
str = objHttp.ResponseText
arr = Split(str, ",")
Stock = arr(3)
End Function
上述代码不支持代理上网。