Hi,
When I feed a RSS to my website, is that possible to display/ print/ show where the source of each news item is coming from whether it is from BBC or other news channels?
This is the RSS feed which pulls the news from different RSS feed, using yahoo pipe, http://pipes.yahoo.com/pipes/pipe.run?_ ... render=rss
For instance,
National Media Briefing (title)
Citizens Advice, Save the Children, Hafal and Plantlife International are in the news today (description)
15 May, 10:29 (pubDate)
BBC (source?)
Election 2009: Numbers game sans big issues (Calcutta News) (title)
Varun Gandhi's hate speech, BJP's attack on Manmohan Singh as 'a weak prime minister' and the hitba... (description)
15 May, 10:17 (pubDate)
CNN (source?)
Thanks,
Lau
The source of each news item of a RSS feed
Moderator: General Moderators
-
lauthiamkok
- Forum Contributor
- Posts: 153
- Joined: Wed Apr 01, 2009 2:23 pm
- Location: Plymouth, United Kingdom
Re: The source of each news item of a RSS feed
I don't know how specifically you have yours setup, but as a way of identifying sources for all the feeds I use with Magpie, I made the following.
I edited it to showcase how you can do it.
Add as many sources as you need.
I edited it to showcase how you can do it.
Code: Select all
$feeds = array ('link1', 'link2', 'link3', 'link4');
foreach ($feeds as $feed ) {
$rss = fetch_rss($feed);
foreach ($rss->items as $item ) {
$url = $item['link'];
$title = $item['title'];
$desc = $item['description'];
$date = $item['date_timestamp'];
$bbc = strpos($url, 'bbc.com');
$yahoo = strpos($url, 'yahoo.com');
$cnn = strpos($url, 'cnn.com');
if ($bbc == true) {
//your output code here with BBC as source
} if ($yahoo == true) {
//your output code here with Yahoo as source
} //etc...
}
}-
lauthiamkok
- Forum Contributor
- Posts: 153
- Joined: Wed Apr 01, 2009 2:23 pm
- Location: Plymouth, United Kingdom
Re: The source of each news item of a RSS feed
this is great. thank you very much.divito wrote:I don't know how specifically you have yours setup, but as a way of identifying sources for all the feeds I use with Magpie, I made the following.
I edited it to showcase how you can do it.
Add as many sources as you need.Code: Select all
$feeds = array ('link1', 'link2', 'link3', 'link4'); foreach ($feeds as $feed ) { $rss = fetch_rss($feed); foreach ($rss->items as $item ) { $url = $item['link']; $title = $item['title']; $desc = $item['description']; $date = $item['date_timestamp']; $bbc = strpos($url, 'bbc.com'); $yahoo = strpos($url, 'yahoo.com'); $cnn = strpos($url, 'cnn.com'); if ($bbc == true) { //your output code here with BBC as source } if ($yahoo == true) { //your output code here with Yahoo as source } //etc... } }
cheers,
Lau