2

我想在简单的 html 页面上显示 NSE 和 BSE 的所有股票价格。

我从谷歌得到信息,我可以调用任何已经存在的网络服务,他们将以 json 形式提供所有信息。然后我必须解析那个 jason 代码。

现在我希望有人为我提供链接,我可以通过该链接调用网络服务。让我知道如何使用 jQuery 调用该 Web 服务。以及如何解析输出 json 数据。如果有人可以给我示例代码,那将是最好的..

非常感谢你帮助我.. :)

4

5 回答 5

9

如果您想从 NSE 网络服务获取数据,那么下面是链接:

http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/ajaxGetQuoteJSON.jsp?symbol=dhfl

但我不确定您是否可以将此链接用于非商业和商业目的。

由于站点已更新且旧站点不再工作,因此使用新的更新链接更新答案:

股票链接 - https://www.nseindia.com/api/quote-equity?symbol=RELIANCE https://www.nseindia.com/api/quote-equity?symbol=RELIANCE§ion=trade_info

衍生品链接: https ://www.nseindia.com/api/quote-derivative?symbol=RELIANCE

我不确定您是否可以将此链接用于非商业和商业目的

于 2015-12-26T12:58:27.363 回答
6

对于免费服务,您可以调用 google 金融网络服务或 yahoo 金融网络服务,但两者都已弃用但仍在工作。

http://finance.yahoo.com/webservice/v1/symbols/IDFC.NS/quote?format=json&view=detail

在上面的 URL 中:IDFC 是安全的象征 .NS 代表 NSE

对于 BSE,只需将 NS 修改为 BO

对于谷歌网络服务:NSE: http: //finance.google.com/finance/info? client=ig&q=NSE:DHFL

对于 BSE,只需将 NSE 修改为 BOM

只需在浏览器中复制以上链接即可查看 json 输出。

于 2015-12-26T08:42:06.257 回答
3

请访问GitHub 库。它肯定会有所帮助。

目前,它提供来自 NSE 官方网站的实时库存。

此服务将为您提供 json 响应,您可以解析此 JSON 以获得适当的值,只需将符号替换为有效的 NSE 代码。

于 2014-05-25T16:46:03.483 回答
2

Google 为 NSC 和 BOM 数据提供免费的网络服务。

https://finance.google.com/finance?q=NSE:KELLTONTEC&output=json

对于谷歌网络服务 NSE 数据- https://finance.google.com/finance?q=NSE:KELLTONTEC&output=json

对于谷歌网络服务 BSE (BOM) 数据- https://finance.google.com/finance?q=BSE:KELLTONTEC&output=json

在 PHP 中

$bse = file_get_contents("https://finance.google.com/finance?q=BSE:KELLTONTEC&output=json");
$split_slash= str_replace('//','',$bse );
$split_data = stripslashes(html_entity_decode($split_slash));
$data = json_decode($split_data);
$equity = $data[0]->l;
print_r($data[0]->l);

它返回 BSE 数据

于 2017-11-27T06:24:33.620 回答
0

从 NSE 获取实时更新的 C# 代码:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Web;
using Newtonsoft.Json.Linq; //download Newtonsoft dll from web
using Newtonsoft.Json;

namespace Check
{
    class Program
    {
        static void Main(string[] args)
        {
            //IDFCBANK

        string[] item = {"ICICIBANK","HDFCBANK"}; 

        foreach(string str in item ) 
        {
            string url = "http://finance.google.com/finance/info?client=ig&q=NSE:" + str;
            string output = "";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            try
            {
                WebResponse response = request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                    output = reader.ReadToEnd();
                    write(output);
                }
            }
            catch (WebException ex)
            {
                Console.WriteLine("Item invalid : " + str);
            }
        }

        Console.ReadKey();

    }

    static void write(string res)
    {
        try 
        {
            if (res.Length > 0)
            {
                res = res.Replace("[", "").Replace("]", "");
                JObject rss = JObject.Parse(res);

                string Title = (string)rss["t"];
                string Time = (string)rss["ltt"];
                string Charge = (string)rss["l"];
                string Change = (string)rss["c"];
                // James Newton-King
                Console.WriteLine(Title.Substring(0,3) + " " + Time + " " + Charge + "  " + Change);


            }

        }
       catch (Exception  ex)
       {
       }
        }

    }
}
于 2017-06-02T07:34:45.407 回答