【问题标题】:Get first n entries from rss or atom feed using YQL and feednormalizer使用 YQL 和 feednormalizer 从 rss 或 atom 提要中获取前 n 个条目
【发布时间】:2016-03-09 15:16:16
【问题描述】:

我正在使用 YQL 以 JSON 格式检索 RSS 和 ATOM 提要,并使用提要规范化器表将它们规范化为 ATOM 样式。

select * from feednormalizer where output='atom_1.0' AND url='http://feeds.delicious.com/v2/rss/msuweb'

我只需要获取前 X 个条目。我知道,理论上,an xpath expression should be able to do that。但是,当我尝试一个我认为应该可以工作的...

select * from feednormalizer where output='atom_1.0' AND url='http://feeds.delicious.com/v2/rss/msuweb' AND xpath='//entry[count(preceding::entry) < 5]'

...结果对象返回 null。我还在 xpath 查询中尝试了using item instead of entry,因为这就是 RSS 提要在实际 XML 中的内容。这也会返回一个空结果对象。

我尝试过的其他东西

限制

我也尝试过使用both local and remote limits,它返回的条目数与我没有指定限制一样。

select * from feednormalizer(0,5) where output='atom_1.0' AND url='http://feeds.delicious.com/v2/rss/msuweb'

select * from feednormalizer where output='atom_1.0' AND url='http://feeds.delicious.com/v2/rss/msuweb' limit 6

使用 CrossProduct 选择列

值得注意的是,我仍然需要典型的 select * 查询附带的所有元数据。也就是说,我需要提要的标题、链接等,而且我希望它们留在根元素中。所以,我知道我能做到

select title, link, entry from feednormalizer(0,6) where output='atom_1.0' AND url='http://feeds.delicious.com/v2/rss/msuweb'

select title, link, entry from feednormalizer where output='atom_1.0' AND url='http://feeds.delicious.com/v2/rss/msuweb' limit 6

但这会将标题和提要链接直接放在列表中的每个条目上,即使在 URL 字符串中使用 crossProduct=optimized 也是如此。叫我挑剔,但我不想那样做。

【问题讨论】:

    标签: xml xpath rss yql atom-feed


    【解决方案1】:

    可能真的晚了,但对于像我这样有同样问题的其他人,我完成了 2 个请求。第一个元数据:

    select * from feednormalizer 
    where output='atom_1.0' 
    AND url='http://feeds.delicious.com/v2/rss/msuweb'
    

    第二个限制数据:

    select title, link, entry 
    from feednormalizer(0,6) 
    where output='atom_1.0' 
    AND url='http://feeds.delicious.com/v2/rss/msuweb'
    

    !未优化但有效!

    【讨论】:

      猜你喜欢
      • 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
      相关资源
      最近更新 更多