Scan website for RSS feeds

I would like a function that can scan website for rss feeds.
I guess the easiest way would be to find the
<link rel=“alternate” href=“rss.xml” type=“application/rss+xml”> tag.

But i don’t know where to start, except for maybe file_get_contents(“http://website/”);

Help is really appreciated.

just scrape the page contents with a regexp


$siteUrl = 'http://foo.com';
$feeds = array();
$matches = array();
if( preg_match_all( '/<link (.*?)type=([\\'"])?application\\/rss\\+xml$2.*?>/is', file_get_contents($siteUrl), $matches ) ) {
    preg_match_all( '/href=([\\'"])?(.*?)$1/is', implode($matches[0]), $feeds );
}
//$feeds[2] is an array of the feeds on the page

Hi!

I know this is an old thread, but it’s still relevant.

I’ve just tried the code and I can’t get it to work with any of the websites I’m running it against.

Might that be due to the passing of time?

If so, could you please post updated regular expressions?

Thanks!