Excel中读取股票信息的自定义函数

来源:互联网 发布:软件开发委托合同 编辑:程序博客网 时间:2024/05/03 08:18

来源: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

上述代码不支持代理上网。


原创粉丝点击