使用Jquery解析货币YQL

发布于 2024-12-29 03:23:23 字数 899 浏览 4 评论 0原文

因为我可以使用 Jquery 解析此查询 YQL。 我看不到信息 非常感谢

Json

    {
 "query": {
  "count": 2,
  "created": "2012-01-25T18:58:01Z",
  "lang": "en-US",
  "results": {
   "span": [
    {
     "id": "yfs_l10_audmxn=x",
     "content": "13.8172"
    },
    {
     "id": "yfs_l10_audmxn=x",
     "content": "13.8172"
    }
   ]
  }
 }
}

Jquery

        <script>
        $(function(){
           $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fmx.finance.yahoo.com%2Fq%3Fs%3DAUDMXN%3DX%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22yfs_l10_audmxn%3Dx%22%5D'&format=json&callback=", function(data){
               $('#currency').html(data.query['results'].span);
           }); 
        });
    </script>

tnks =)

As I can parse this query YQL using Jquery.
I can not see the information
thank you very much

Json

    {
 "query": {
  "count": 2,
  "created": "2012-01-25T18:58:01Z",
  "lang": "en-US",
  "results": {
   "span": [
    {
     "id": "yfs_l10_audmxn=x",
     "content": "13.8172"
    },
    {
     "id": "yfs_l10_audmxn=x",
     "content": "13.8172"
    }
   ]
  }
 }
}

Jquery

        <script>
        $(function(){
           $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fmx.finance.yahoo.com%2Fq%3Fs%3DAUDMXN%3DX%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22yfs_l10_audmxn%3Dx%22%5D'&format=json&callback=", function(data){
               $('#currency').html(data.query['results'].span);
           }); 
        });
    </script>

tnks =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

给我一枪 2025-01-05 03:23:23

货币信息就在那里。我不知道为什么你看不到它。
也许您应该使用这个,

$('#currency').html(data.query['results'].span[0].content);

data.query['results'].span[0].content 包含13.8172
这意味着 MXN 1 = AUD 13.8172

The currency information is there. I dont know why you dont see it.
May be you should use this,

$('#currency').html(data.query['results'].span[0].content);

data.query['results'].span[0].content contains 13.8172.
Thats means MXN 1 = AUD 13.8172

深海蓝天 2025-01-05 03:23:23
 $(function(){
           $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fmx.finance.yahoo.com%2Fq%3Fs%3DAUDMXN%3DX%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22yfs_l10_audmxn%3Dx%22%5D'&format=json&callback=", function(data){
       $("span").html(data.query.count);
       $("#created").html(data.query.created);
       $("#lang").html(data.query.lang);
$(data.query.results.span).each(function(index,elem){
 $.each(elem,function(k,v){
  $("<tr/>").append("<td> "+k+" </td><td> "+v+" </td>").appendTo("table");
    })
   });
  });
});

演示

 $(function(){
           $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fmx.finance.yahoo.com%2Fq%3Fs%3DAUDMXN%3DX%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22yfs_l10_audmxn%3Dx%22%5D'&format=json&callback=", function(data){
       $("span").html(data.query.count);
       $("#created").html(data.query.created);
       $("#lang").html(data.query.lang);
$(data.query.results.span).each(function(index,elem){
 $.each(elem,function(k,v){
  $("<tr/>").append("<td> "+k+" </td><td> "+v+" </td>").appendTo("table");
    })
   });
  });
});

DEMO

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文