Page 1 of 1

The source of each news item of a RSS feed

Posted: Fri May 15, 2009 6:22 am
by lauthiamkok
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

Re: The source of each news item of a RSS feed

Posted: Fri May 15, 2009 6:39 am
by divito
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.

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...
 
}
}
Add as many sources as you need.

Re: The source of each news item of a RSS feed

Posted: Fri May 15, 2009 7:10 am
by lauthiamkok
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.

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...
 
}
}
Add as many sources as you need.
this is great. thank you very much.
cheers,
Lau