【问题标题】:Yahoo YQL RSS returning no results雅虎 YQL RSS 未返回任何结果
【发布时间】:2017-02-23 17:18:35
【问题描述】:

YQL 有点问题。我正在尝试从 URL 查询 RSS,但没有得到任何结果。

输入了这个查询:

select title from rss where url="http://www.spoilertv.com/feeds/posts/default/-/Aftermath"

...而不是按要求获取标题,控制台显示:

<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
    yahoo:count="0" yahoo:created="2017-02-23T17:13:16Z" yahoo:lang="en-US">
    <diagnostics>
        <publiclyCallable>true</publiclyCallable>
        <url execution-start-time="1" execution-stop-time="101"
            execution-time="100" id="5080cef9-75a4-4356-9b08-1d68fb3d855d"><![CDATA[http://www.spoilertv.com/feeds/posts/default/-/Aftermath]]></url>
        <user-time>118</user-time>
        <service-time>100</service-time>
        <build-version>2.0.84</build-version>
    </diagnostics> 
    <results/>
</query>

可能出了什么问题?

【问题讨论】:

    标签: javascript rss yql yahoo-api


    【解决方案1】:

    当我使用 YQL 向您的 URL 示例发出一些请求时,我有两个结果,以 JSON 或 XML 格式获取结果,它总是 NULL

    据此link

    YQL 只生成 xml 或 json。您可以创建 rss 或 atom 提要,但它 总是在 yql 根元素内。所以你需要另一个工具 从响应中提取提要。我正在使用 Google Apps 脚本 那。它可以解析和创建 xml/rss 并使用服务器端 javascript 例如:

    var url = 'http://query.yahooapis.com/v1/public/yql?q=...'; // rest query to YQL table
    var xml = UrlFetchApp.fetch(url).getContentText(); // this is an xml string
    var root = XmlService.parse(xml).getRootElement(); // now we can modify this xml or create a new one.
    

    我建议您改为进行以下测试:

    检查此link 并按照步骤#6:

    单击复制 URL。从 yql_news_app.html 中,将 URL 粘贴到 src 第二个脚本标记的属性如下所示 在您的情况下 你可以检查如下

    <body>
      <div id='results'></div>
      <escript src='https://query.yahooapis.com/v1/public/yql?q=select%20title%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.spoilertv.com%2Ffeeds%2Fposts%2Fdefault%2F-%2FAftermath%22&diagnostics=true'>
      </escript>
    </body>
    

    在您的浏览器中,按 F12 (并检查控制台选项卡)。看看有没有错误。如果是这样,请用结果的详细信息更新您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-27
      • 2014-02-01
      • 1970-01-01
      • 2023-03-15
      • 2018-02-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多