Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get an RSS feed's title using YQL

Tags:

rss

yql

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

like image 877
Bagelzone Ha'bonè Avatar asked Oct 24 '22 11:10

Bagelzone Ha'bonè


1 Answers

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)

like image 178
salathe Avatar answered Jan 02 '23 21:01

salathe