使用网络服务获取NSE和BSE的股票报价,并使用json解析它

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

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

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

非常感谢你帮助我.. 🙂

如果要从NSE Web服务获取数据,则下面是链接:

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

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

对于免费服务,您可以拨打谷歌财务网络服务或雅虎财务网络服务,但两者都已弃用但仍在使用。

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

在上面的URL中:IDFC是安全性的符号.NS代表NSE

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

对于Google网络服务:NSE: http : //finance.google.com/finance/info?client = zh& q = nsE: DHFL

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

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

请转到此 GitHub库。 这肯定会有所帮助。

目前它从官方NSE网站提供实时库存。

此服务将为您提供json响应,您可以通过仅使用有效的NSE代码替换该符号来解析此JSON以获取适当的值。

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

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

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

对于Google Web服务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数据

从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) { } } } }