开发者

Limiting and handling errors in YQL RSS feednormalizer

I'm using YQL to retrieve several RSS feeds (channels) at once, using the following query:

SELECT * FROM feednormalizer
WHERE output="rss_2.0"
AND url in ("http://rss.cnn.com/rss/edition.rss",
            "http://bad.url.com/nothing",
            "http://rss.cnn.com/rss/edition_space.rss")

so i actually have 2 questions:

  1. How can i limit each feed to a certain amount of items? (for example, I want to get top 3 items from each channel)
  2. Notice that the 2nd URL is invalid (not a URL of a real RSS). in that case, the YQL result returns 2 valid ch开发者_如何学Goannels plus an error, but there is no indication of which URLs are valid and which one failed.

    in other words - for each result feed, there is no indication from which URL it arrived.

    any ideas as to how identify each channel?

thanks


1st question:

the first thought that comes to mind is using query.multi:

SELECT rss.channel.item FROM query.multi WHERE queries="
   SELECT channel.item FROM feednormalizer WHERE output='rss_2.0' AND url = 'http://rss.cnn.com/rss/edition.rss' LIMIT 3; 
   SELECT channel.item FROM feednormalizer WHERE output='rss_2.0' AND url = 'http://rss.cnn.com/rss/edition_space.rss' LIMIT 3;"

Not the most elegant way but it works.

2nd question:

I don't think it is possible. As YQL's WHERE x IN ()... syntax is not really an SQL join, it is not possible to select parts of the inner subquery in the projection, what you would need for your case.

Would be happy if anybody would proove me wrong on this one, as I needed that a couple of times myself and always had to work around it programatically :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜