2011-08-31 93 views

回答

3

我不知道任何免费的网络服务。此外,我不知道有什么与现场数据的一分钟。

但是,例如欧洲央行每天都会按照汇率发布xml。 此代码每个数据到数据库粘贴,你可以自定义它只能获得INR到USD:

public class CurrencyUpdate : IHttpHandler 
{ 
    public bool IsReusable 
    { get { return true; } } 
    public void ProcessRequest(HttpContext ctx) 
    { 
     NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat; 
     XmlReader reader = XmlReader.Create("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"); 
     string code = ""; 
     decimal rate = 0; 
     while (reader.ReadToFollowing("Cube")) 
     { 

      if (reader.AttributeCount==2) 
      { 
       rate = decimal.Parse(reader.GetAttribute("rate").ToString(),nfi); 
       code = reader.GetAttribute("currency").ToString(); 

       // FunctionToAddCodeAndRateToTheDataBase(code , rate);    
      } 
     } 
     ctx.Response.Write("success"); 

    } 
} 
4

this link

,并使用YQL服务,你可以有更多的利率和各种检索类型(XML和JSON)

使用读取的关于Ajax和JQuery的数据,或者可以使用我的波纹管代码。在Firefox浏览器

使用Firebug在控制台中看到标签

$(document).ready(function(){ 
    console.log("salam"); 
    setInterval("AjaxCall()", 3000); 
    var urlSrevice = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22EURUSD%22%2C%22GBPUSD%22%2C%22IRRUSD%22%2C%22JPYUSD%22)&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"; 
    AjaxCall = function salam(){ 
     $.ajax({ 
      type: "GET", 
      url: urlSrevice, 
      dataType: "xml", 
      success:function(xml){ 
       $('#forex-rate').children().remove(); 
       $(xml).find('rate').each(function(){ 
        var Name = $(this).find('Name').text(); 
        var Rate = $(this).find('Rate').text(); 
        var Date = $(this).find('Date').text(); 
        var Time = $(this).find('Time').text(); 
        var Ask = $(this).find('Ask').text(); 
        var Bid = $(this).find('Bid').text(); 
        console.log($(this).find('Name').text() + " " + Rate.toString() + " " + Date + " " + Time + " " + Ask + " " + Bid); 
       }); 
      } 
     }); 
    } 
}); 
+0

检查该解决方案http://codecanyon.net/item/currency-converter/16408544的实时数据。它使用雅虎金融实时汇率和支持156种货币。 –