找回密码
 加入
搜索
查看: 6422|回复: 6

新浪的股票的数据接口怎么读取?

  [复制链接]
发表于 2010-1-7 20:06:39 | 显示全部楼层 |阅读模式
新浪提供的接口是
新浪的股票数据接口:http://hq.sinajs.cn/list=**********

********** 为股票代码

如:sh600000,sz000913 (这里sh是上海股市,sz为深圳股市)

http://hq.sinajs.cn/list=sh600000

http://hq.sinajs.cn/list=sz000913

访问: http://hq.sinajs.cn/list=sh601006 返回

var hq_str_sh601006="大秦铁路, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92, 

22114263, 589824680, 4695, 26.91, 57590, 26.90, 14700, 26.89, 14300,

26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, 2008-01-11, 15:05:32";

这个字符串由许多数据拼接在一起,不同含义的数据用逗号隔开了,按照程序员的思路,顺序号从0开始。

0:”大秦铁路”,股票名字;

1:”27.55″,今日开盘价;

2:”27.25″,昨日收盘价;

3:”26.91″,当前价格;

4:”27.55″,今日最高价;

5:”26.20″,今日最低价;

6:”26.91″,竞买价,即“买一”报价;

7:”26.92″,竞卖价,即“卖一”报价;

8:”22114263″,成交的股票数,由于股票交易以一百股为基本单位,通常把该值除以一百;

9:”589824680″,成交金额,单位为“元”,通常以“万元”为成交金额的单位,所以通常把该值除以一万;

10:”4695″,“买一”申请4695股,即47手;

11:”26.91″,“买一”报价;

12:”57590″,“买二”

13:”26.90″,“买二”

14:”14700″,“买三”

15:”26.89″,“买三”

16:”14300″,“买四”

17:”26.88″,“买四”

18:”15100″,“买五”

19:”26.87″,“买五”

20:”3100″,“卖一”申报3100股,即31手;

21:”26.92″,“卖一”报价

(22, 23), (24, 25), (26,27), (28, 29)分别为“卖二”至“卖五的情况”

30:”2008-01-11″,日期;

31:”15:05:32″,时间;
请高手给一段代码,每3秒读取一次SH600000浦发银行的最新价格和涨幅显示出来。
发表于 2010-1-7 23:52:48 | 显示全部楼层
本帖最后由 remme 于 2010-1-8 09:46 编辑
while 1

    Local $hDownload = InetGet("http://hq.sinajs.cn/list=sh600000", "sh600000.txt", 1, 1)
    InetClose($hDownload)  

    $file = FileOpen("sh600000.txt", 0)

    ; Check if file opened for reading OK
    If $file = -1 Then
        MsgBox(0, "Error", "Unable to open file.  a time until the EOF is reached")
    EndIf

    While 1
        $chars = FileRead($file)
        If @error = -1 Then ExitLoop
        $aArray = StringTrimLeft($chars,21)
        $aArray = StringTrimRight($aArray,7)
        $aArray = StringSplit($aArray,",")
        TrayTip($aArray[1], "最新股价" & $aArray[4], 10, 1)
      sleep(2500)
    Wend

    FileClose($file)
WEnd
 楼主| 发表于 2010-1-8 12:13:30 | 显示全部楼层
谢谢,原来是下载成txt文件,有没有不下载,直接取得字符串再进行数组处理的办法?
发表于 2010-1-8 13:20:45 | 显示全部楼层
回复 3# manlty
While 1
        Local $HTML = BinaryToString(InetRead('http://hq.sinajs.cn/list=sh600000'))
        $aArray = StringSplit($HTML, ',')
        ToolTip('当前价: ' & $aArray[4] & ' | 涨跌幅: ' & Round($aArray[4] - $aArray[3], 2), 0, 0, '浦发银行', 1)
        Sleep(3000)
WEnd

评分

参与人数 1金钱 +10 收起 理由
顽固不化 + 10

查看全部评分

发表于 2010-1-20 17:00:28 | 显示全部楼层
学习下,不错,感谢
发表于 2010-1-21 07:51:02 | 显示全部楼层
不错,学习下
发表于 2010-1-21 11:46:42 | 显示全部楼层
新版本有这些函数吗 InetClose  InetRead
看来我OUT了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 08:12 , Processed in 0.079588 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表