【问题标题】:YQL - Not able to return yql resultsYQL - 无法返回 yql 结果
【发布时间】:2011-10-31 00:07:07
【问题描述】:

我正在尝试归还所有的

我正在使用其余查询查询的页面上的超链接。

这是我用的yql查询

select * from html where url="http://www.stickam.com/videoPlaylist.do?uId=182005497" and xpath="//*[@class='mediaThum']/a"

or the permilink to my yql

这里是代码

<script src="jquery.1.6.1.js"></script>
<script>

$(document).ready(function(){
    var yql = "http://query.yahooapis.com/v1/public/yql?q=%20SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.stickam.com%2FvideoPlaylist.do%3FuId%3D182005497%22%20and%20xpath%3D%22%2F%2F*%5B%40class%3D'mediaThum'%5D%2Fa%22%20";

    $.get( yql, cbFunc );

    function cbFunc(data) {

    alert(data.query.results.a[0].href);

    }//END FUNC
});//end document.ready
</script>

谢谢安东尼。

【问题讨论】:

    标签: javascript jquery yql


    【解决方案1】:

    有几个小问题,我只介绍其中的几个。

    • 向 YQL 请求 JSON

      您需要告诉 YQL,您希望从查询中得到 JSON 格式的响应。 YQL url 必须包含format=json

      var yql = "http://query.yahooapis...%22%20&format=json";
      
    • 从 jQuery 请求 JSON

      使用$.getJSON 函数代替$.get

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多