Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

how to get news feed into webpage

Options
  • 15-04-2008 4:58pm
    #1
    Closed Accounts Posts: 401 ✭✭


    I am setting up a webpage and i want some news from rte.ie or independent.ie or bbc or sky to "feed" into the site and appear in a table or appear as a horizontal scrolling bar across the webpage.

    How can i do this - maybe with RSS or cut and pasting some code into the HTML of my webpage


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    Some sites provide HTML/Javascript code that you can include on your site.

    However most times all you get is an rss feed that you need to parse yourself using ASP/PHP, etc


  • Closed Accounts Posts: 401 ✭✭culabula88


    Can you explain how to do this - for example to stream the sports news from RTE webpage?


  • Closed Accounts Posts: 238 ✭✭chat2joe


    I'd recommend trying using the RSS feed on this site - http://itde.vccs.edu/rss2js/build.php

    Mess around with the setting until you get something that looks like what you want. Then they'll give you the code to put into your html.

    You can then play with a stylesheet to make it fit the format of your page.

    I used it a while back as a handy way to get a BBC weather feed on this page.

    ;)


  • Registered Users Posts: 2,809 ✭✭✭edanto


    Thanks for the link to that page - I used it to make a wee widget for http://www.suas.ie/eventsanddiscussion.html and it's working grand.

    I had been looking for a while for a widget that didn't have a sponsored linke. Much appreciated!


  • Closed Accounts Posts: 238 ✭✭chat2joe


    Very nicely integrated into the site! Might just do the same with a forum feed on a site of my own!

    The Suas site is looking great! I made the NUIG Suas site a while back! It's not being updated though - must put a few hours work into it over the Summer and get the current committee up to speed on how to update it!


  • Advertisement
  • Registered Users Posts: 2,809 ✭✭✭edanto


    Yeah it didn't update with a post that I made this morning though - not quite sure what's going on. I'm sure it's only a teething problem.

    How's the NUIG site looking? Would you like to use nuig.suas.ie ? I think I could set up a pointer, not really sure. Actually a thread on the Suas forum with links to all the Soc webpages would be well good. Wanna start it?!


  • Registered Users Posts: 7,518 ✭✭✭matrim


    Here's some php code that I've used before to read the rss feed from the rte site.
    <?php
    $rssFeeds = 'http://www.rte.ie/rss/news.xml';
    // for now we'll just have the one file, but this can later be expanded
    //Loop through the array (just one element for now) and read the feedforeach  
    	readFeeds($rssFeeds);
    
    
    
    // The function to be called when a start element is read. For now we'll 
    // just echo some outputfunction 
    function startElement($xp,$name,$attributes) 
    {  
    	global $item,$currentElement;  $currentElement = $name; 
    	//the other functions will always know which element we're parsing  
    	if ($currentElement == 'ITEM') { 
    		//by default PHP converts everything to uppercase    
    		$item = true; 
    		// We're only interested in the contents of the item element. 
    		////This flag keeps track of where we are  
    
    	}
    
    }
    
    function endElement($xp,$name) {  
    	global $item,$currentElement,$title,$description,$link,$pubdate;    
    	if ($name == 'ITEM') { 
    		// If we're at the end of the item element, display 
    		// the data, and reset the globals
    		echo "<tr>"; 
          echo "<td>";
    		echo "<h2 align=\"center\"><a href=\"$link\" alt=\"$link\">$title</a></h2>";
    		echo "<br />$description<br />"; 
    		echo "<br /><hr />";
    		echo "</tr>"; 
          echo "</td>";
    		$title = '';    
    		$description = '';    
    		$link = ''; 
    		$pubdate = '';
    		$item = false;  
    	}
    }
    
    function characterDataHandler($xp,$data) {  
    	global $item,$currentElement,$title,$description,$link,$pubdate;    
    	if ($item) { 
    		//Only add to the globals if we're inside an item element.    
    		switch($currentElement) {      
    			case "TITLE":        
    				$title .= $data; 
    				// We use .= because this function may be called multiple 
    				// times for one element.        
    			break;      
    			case "DESCRIPTION":        
    				$description.=$data;        
    			break;      
    			case "LINK":        
    				$link.=$data;        
    			break;   
    			case "PUBDATE":        
    				$pubdate.=$data;        
    			break;
    		}  
    	}
    }
    
    function readFeeds($feed) {  
    	$fh = fopen($feed,'r'); 
    	// open file for reading  
    	$xp = xml_parser_create(); 
    	// Create an XML parser resource  
    	xml_set_element_handler($xp, "startElement", "endElement"); 
    
    	 xml_set_character_data_handler($xp, "characterDataHandler");
    	// defines which functions to call when element started/ended  
    	while ($data = fread($fh, 4096)) {    
    		if (!xml_parse($xp,$data)) {      
    			return 'Error in the feed';    
    		}  
    	}
    }	
    ?>
    


  • Registered Users Posts: 2,809 ✭✭✭edanto


    edanto wrote: »
    Yeah it didn't update with a post that I made this morning

    Found that all I had to do was tweak the options on the rss - using http://www.suas.ie/vbulletin/external.php?lastpost=true&type=rss2 now and it's grand.

    by the by, here's the code, but it was made by the vccs.edu site that chat2joe linked to.
    <script language="JavaScript" src="http://itde.vccs.edu/rss2js/feed2js.php?src=http%3A%2F%2Fwww.suas.ie%2Fvbulletin%2Fexternal.php%3Flastpost%3Dtrue%26type%3Drss2&chan=n&num=7&desc=150&date=n&targ=n" type="text/javascript"></script>
    
    <noscript>
    <a href="http://itde.vccs.edu/rss2js/feed2js.php?src=http%3A%2F%2Fwww.suas.ie%2Fvbulletin%2Fexternal.php%3Flastpost%3Dtrue%26type%3Drss2&chan=n&num=7&desc=150&date=n&targ=n&html=y">View RSS feed</a>
    </noscript>
    


Advertisement