开发者

Get an RSS feed's title using YQL

开发者 https://www.devze.com 2023-03-08 00:00 出处:网络
I\'m using YQL to retrieve an RSS feed using javascript (as json), for example i use the following query:

I'm using YQL to retrieve an RSS feed using javascript (as json), for example i use the following query:

select * from rss where url = "http://feeds2.feedburner.com/ajaxian"

The response contains the feed items, already parsed as json and everything is cool so far.

Now, I also want to get the title of the entire feed (not the title of a specific item) - but it's not a part of the result (even though the original XML feed contains it).

There is the possibility of querying the original XML itself. for example:

select channel.title from xml where url = "http://feeds2.feedburner.com/ajaxian"

and it ind开发者_开发知识库eed returns the feed title for that specific RSS, but that query is only valid for a RSS 2.0 formatted feeds, which stores it under rss\channel\title.

What about atom feeds which store the title under feed\title ?

What about other formats?

My question is - is there any generic way to request the feed's title through YQL? maybe somehow along with the feed itself?

thanks,


You can use the feednormalizer table to convert the feed (regardless of its format) into one of the standard formats, then grab the title from the proper node for that format.

To take the Ajaxian feed, "normalize" it as Atom and get the feed title, the query would look like:

SELECT title
FROM   feednormalizer
WHERE  output="atom_1.0" AND url="http://feeds2.feedburner.com/ajaxian"

(Try this in the YQL console)


There are also other tables that you can use like feed, rss and atom.

Regarding your follow up question of how to find data tables:

Go to the YQL console, make sure that the Community Tables are loaded (should already be the case with this link) and then just type in the search box on the right hand side what you are looking for. Often you can find something useful.

0

精彩评论

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