新浪接口会给出实时的买一到买五和卖一到卖五的量价和数据时间,下面程序只是给了个简单的示例来获得当前价格,对比下数据时间会发现有延时10秒左右,另外为了拓展方便我分别用c++和c#各写了个获取的程序,如果有需要的话可以放出来(其实原理一样的,获取+字符串分拆)
<br />
require(RCurl)<br />
A=read.csv("Acode",stringsAsFactors=F)<br />
rownames(A)=A$X<br />
A=A[-1]<br />
lis=read.csv("RURL",stringsAsFactors=F)$x<br />
l=length(A$id)<br />
n=220 #一次扫描数目<br />
txt=getURL(paste('http://hq.sinajs.cn/list=',lis,sep=''))<br />
temp=strsplit(unlist(strsplit(txt,"\n")),",")<br />
for(i in temp){<br />
A[substr(i[1],12,19),"now"]=as.numeric(i[4])<br />
}<br />
</p>