使用 JQuery+json 擷取163 股票資訊

來源:互聯網
上載者:User

1 希望能即時查看股票資訊變化,比較了新浪,網易,yahoo的股票API, yahoo 延遲15分鐘, 新浪的返回資料是 csv格式, 網易返回的是 json 格式。所以選用了網易的股票API。

2 查詢股票資訊 使用如下格式的請求

[html]
http://api.money.126.net/data/feed/1000002,1000001,1000881,money.api 
股票代號之間使用逗號分隔,股票代號的命名規則參見 網易財經的規則。

返回的json 結果如下:

[plain] 
_ntes_quote_callback({ 
    "1000002": { 
        "code": "1000002", 
        "percent": -0.012731481481481621, 
        "high": 8.6999999999999993, 
        "askvol3": 10700, 
        "askvol2": 41700, 
        "askvol5": 22500, 
        "askvol4": 36822, 
        "price": 8.5299999999999994, 
        "open": 8.6300000000000008, 
        "bid5": 8.4800000000000004, 
        "bid4": 8.4900000000000002, 
        "bid3": 8.5, 
        "bid2": 8.5099999999999998, 
        "bid1": 8.5199999999999996, 
        "low": 8.5, 
        "updown": -0.11000000000000121, 
        "type": "SZ", 
        "bidvol1": 1000, 
        "bidvol3": 168500, 
        "bidvol2": 63395, 
        "symbol": "000002", 
        "update": "2012/08/17 13:46:28", 
        "bidvol5": 215300, 
        "bidvol4": 176600, 
        "volume": 17132617, 
        "askvol1": 11413, 
        "ask5": 8.5700000000000003, 
        "ask4": 8.5600000000000005, 
        "ask1": 8.5299999999999994, 
        "name": "\u4e07  \u79d1\uff21", 
        "ask3": 8.5500000000000007, 
        "ask2": 8.5399999999999991, 
        "arrow": "\u2193", 
        "time": "2012/08/17 13:46:20", 
        "yestclose": 8.6400000000000006, 
        "turnover": 147404890.41999999 
    }, 
    "1000001": { 
        "code": "1000001", 
        "percent": 0.0093896713615023858, 
        "high": 15.1, 
        "askvol3": 71712, 
        "askvol2": 135132, 
        "askvol5": 392350, 
        "askvol4": 111230, 
        "price": 15.050000000000001, 
        "open": 14.91, 
        "bid5": 15.01, 
        "bid4": 15.02, 
        "bid3": 15.029999999999999, 
        "bid2": 15.039999999999999, 
        "bid1": 15.050000000000001, 
        "low": 14.880000000000001, 
        "updown": 0.14000000000000057, 
        "type": "SZ", 
        "bidvol1": 265, 
        "bidvol3": 39983, 
        "bidvol2": 15060, 
        "symbol": "000001", 
        "update": "2012/08/17 13:46:28", 
        "bidvol5": 50349, 
        "bidvol4": 24437, 
        "volume": 7187625, 
        "askvol1": 67847, 
        "ask5": 15.1, 
        "ask4": 15.09, 
        "ask1": 15.06, 
        "name": "\u5e73\u5b89\u94f6\u884c", 
        "ask3": 15.08, 
        "ask2": 15.07, 
        "arrow": "\u2191", 
        "time": "2012/08/17 13:46:20", 
        "yestclose": 14.91, 
        "turnover": 107989733.23 
    }, 
    "1000881": { 
        "code": "1000881", 
        "percent": -0.014388489208633001, 
        "high": 8.3800000000000008, 
        "askvol3": 500, 
        "askvol2": 47500, 
        "askvol5": 3100, 
        "askvol4": 2978, 
        "price": 8.2200000000000006, 
        "open": 8.3000000000000007, 
        "bid5": 8.1899999999999995, 
        "bid4": 8.1999999999999993, 
        "bid3": 8.2100000000000009, 
        "bid2": 8.2200000000000006, 
        "bid1": 8.2300000000000004, 
        "low": 8.2100000000000009, 
        "updown": -0.11999999999999922, 
        "type": "SZ", 
        "bidvol1": 1000, 
        "bidvol3": 38154, 
        "bidvol2": 5611, 
        "symbol": "000881", 
        "update": "2012/08/17 13:46:28", 
        "bidvol5": 28500, 
        "bidvol4": 32200, 
        "volume": 1652944, 
        "askvol1": 12262, 
        "ask5": 8.2899999999999991, 
        "ask4": 8.2799999999999994, 
        "ask1": 8.2400000000000002, 
        "name": "\u5927\u8fde\u56fd\u9645", 
        "ask3": 8.2599999999999998, 
        "ask2": 8.25, 
        "arrow": "\u2193", 
        "time": "2012/08/17 13:46:20", 
        "yestclose": 8.3399999999999999, 
        "turnover": 13662482.58 
    } 
}); 

3 根據相應的屬性,取出對應的值即可。
相應Jquery處理 Json  代碼參考 http://bingzone.sinaapp.com/JobAlliance/quotes/stock.php


4 取K線圖的地址。
http://img1.quotes.ws.126.net/chart/timechart/1000001.png    分時圖
http://img1.quotes.ws.126.net/chart/kchart/30/1000001.png    30天日K線
http://img1.quotes.ws.126.net/chart/kchart/90/1000001.png    90天日K線
http://img1.quotes.ws.126.net/chart/kchart/180/1000001.png   180天日K線
http://img1.quotes.ws.126.net/chart/kchart/week/1000001.png  周線
http://img1.quotes.ws.126.net/chart/kchart/month/1000001.png 月線
http://img1.quotes.ws.126.net/chart/kchart/180/1000001.png   半年線


 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.