Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,346
    Thanks
    11
    Thanked 589 Times in 570 Posts

    display any RSS feed

    I just came across the YQL service from yahoo, and I am impressed.

    It allows you run an SQL-like query against web searches, web pages, and rss feeds, among other sources.
    The results are available in JSONP, so you can use the service from any website.
    Unlike Pipes, YQL doesn't seem to require any registration to use.

    Using the RSS feature, i was able to build one of my simplest RSS>HTML scripts yet.

    You might want to customize at least the green parts, but this should be enough to get you started...

    view live demo


    source:
    Code:
    <html>
    <head>	<title>News</title>
    <style>
    	body{ background: #fff;}
    	li { padding: 1em; margin-right: 40%;background:#efe; border: 1px solid #000;
    		margin-bottom: 1em;list-style:none;}
    	a { text-decoration: none;font: 133% serif;color:blue;}
    	a:hover { text-decoration: underline;}
    	img {border: 3px solid #000; margin: 0 0.5em;}
    </style>
    </head>
    <body>
    <script>
    
    function request(str){  //request builder (don't modify)
      function addScript(u){ var sc2=document.createElement('script'); 
       sc2.src=u;return document.getElementsByTagName('*')[1].appendChild(sc2) }
     var url="http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent(str)+
      '&format=json&diagnostics=false&callback=incoming';
     return addScript(url);
    }
    
    
    if (![].map) {//for IE and opera compatibility:
     Array.prototype.map=function(fun){var len=this.length,res=new Array(len),t=arguments[1];
     for(var i=0;i<len;i++){if(i in this){res[i]=fun.call(t,this[i],i,this);}}return res;};
    }
    
    
    
    function incoming(ob){ //view builder (customize if needed)
        var r=ob.query.results.item;
        document.body.innerHTML="<ul>"+(r.map(function(a,n){
            return "<li title='"+a.pubDate+"'>"+ 
    		  a.title.link(a.link).big()+ "<br />"+
    		  a.description+
    		"</li>";
        }).join(""))+"</ul>"
    }// end incoming()
    
    
    
    
    //example request:
     request(
    'select title, link, pubDate, description \
    from rss \
    where url="http://www.voanews.com/english/customCF/RecentStoriesRSS.cfm?keyword=Science%20and%20Technology" '
     );
    
    </script>
    </body>
    </html>
    Last edited by rnd me; 10-30-2009 at 03:50 AM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •