Christian Heilmann

Posts Tagged ‘loading’

Using YQL to load and convert RSS feeds really, really fast.

Tuesday, December 8th, 2009

My esteemed colleague Stoyan Stefanov is currently running an advent calendar (blog post a day) on performance. Today I have a guest slot on his blog showing how you can use YQL to retrieve five RSS feeds much faster than with any other technology.

Retrieving five RSS feeds speed comparison.

As stated at the end of the article, you could use a YQL open table with embedded JavaScript to move all of the hard conversion work to the YQL server, too.

This table does exactly that. The speed of the retrieval slows down a bit with this (as YQL needs to do another request to pull the table definition):

Retrieving five RSS feeds and converting it on the server with YQL execute by  you.

However, using this table to retrieve multiple feeds as HTML is dead easy:

$data = array(
$url =’’;
$query = “use ‘’ as m;select * from m where feeds=”’”.implode(“’,’”,$data).”’” and html=’true’ and compact=’true’”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
$content = preg_replace(‘/.*
$content = preg_replace(‘/div>.*/’,’div>‘,$content);
echo $content;

To use the open table you simply need to give it the list of RSS feeds as the feeds parameter:

use ‘’ as m;
select * from m where feeds=”
” and html=’true’ and compact=’true’

Try it out in the YQL console.

The html parameter defines if you want to get HTML back from the table. Take it out to get a list of feeds instead.

See the results as HTML (with an HTML parameter) or as feeds (without the HTML parameter).

The compact parameter defines if you want to get descriptions back for each entry or not.

See the results as HTML (without descriptions) or as HTML with descriptions.

By using the JSON-P-X output format (xml with callback) you could easily use this in JavaScript:

If you want to compare yourself, get the source code of all the examples from GitHub.