如何獲取實時的股票數據?
可以通過調用ChinaStockWebService的服務來實現獲取股票的實時數據,代碼如下:
public string[] getStockInfo(string stockcode) { //string url = "http://hq.sinajs.cn/list="+stockcode; //stockcode 某只股票的代碼 string url = "http://hq.sinajs.cn/list=sh600683"
; WebClient client = new WebClient()
; client.Headers.Add("Content-Type", "text/html; charset=gb2312")
; Stream data = client.OpenRead(url)
; StreamReader reader = new StreamReader(data, Encoding.GetEncoding("gb2312"))
; string s = reader.ReadToEnd()
; reader.Close()
; data.Close()
; return s.Split(','); }