YQL - 无法返回 yql 结果

发布于 2024-12-13 02:54:11 字数 840 浏览 5 评论 0原文

我正在尝试使用其余查询返回

我正在查询的页面上的所有超链接。

这是我使用的 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>

谢谢安东尼。

I am trying to return back all the

hyperlinks on the page that I am querying using the rest query.

this is the yql query I used

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

or the permilink to my yql

here is the code

<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>

Thanks Anthony.

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

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

发布评论

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

评论(1

心如狂蝶 2024-12-20 02:54:11

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

  • 从 YQL 请求 JSON

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

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

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

There are several minor issues, I'll only cover a couple of them.

  • Ask for JSON from YQL

    You need to tell YQL that you're expecting a JSON formatted response from your query. The YQL url must contain format=json.

    var yql = "http://query.yahooapis...%22%20&format=json";
    
  • Ask for JSON from jQuery

    Use the $.getJSON function in place of $.get.

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