YQL -无法返回YQL结果

YQL - Not able to return yql results

本文关键字:YQL 结果 返回      更新时间:2023-09-26

我试图返回所有的

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

这是我使用的yql查询

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

或允许链接到我的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>

谢谢安东尼。

有几个小问题,我将只讨论其中的几个。

  • 从YQL请求JSON

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

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

    $.getJSON功能代替$.get功能