cmple Posted May 10, 2007 Share Posted May 10, 2007 Hi everyone ! I've been trying to find a solution for days... please Help! Basically i need to find an RSS feed on given webpage, lets say: http://news.yahoo.com/rss they don't provide a file extension like: topstories.rss, so the only way for it to work on any page, is to go to the file contents, and parse the first line, if it is: <?xml ..... then consider it as a feed. here is what i tried: $contents = file_get_contents('http://news.yahoo.com/rss'); //Get all contents of the file, $strText = preg_match_all(' Link regEx ', $contents , $value); //take out the links only. $value = array_unique ($value[0]); foreach($value as $key){ $content=file($key); } so the only problem is that: file(); takes the whole file in order to process it, so if the page has lets say 250 links , it would take FOREVER to get all those files, just because i need only 1st line. :-\ Question: is there a way to get only the 1st, 2nd line of the file, and Not loading it in full. or is there another way? Thank you. Link to comment https://forums.phpfreaks.com/topic/50805-detect-rss-feeds-on-page/ Share on other sites More sharing options...
per1os Posted May 10, 2007 Share Posted May 10, 2007 http://us2.php.net/manual/en/function.fread.php If you have url_wrappers or something like that on you could use that. cURL may help ??? http://us2.php.net/manual/en/function.fgets.php That may also help as you can just get the first line. Hope that helps. If all else fails, why not just check for that <?xml string first before parsing the links? Link to comment https://forums.phpfreaks.com/topic/50805-detect-rss-feeds-on-page/#findComment-249819 Share on other sites More sharing options...
cmple Posted May 10, 2007 Author Share Posted May 10, 2007 http://us2.php.net/manual/en/function.fread.php If you have url_wrappers or something like that on you could use that. cURL may help ??? http://us2.php.net/manual/en/function.fgets.php That may also help as you can just get the first line. Hope that helps. If all else fails, why not just check for that <?xml string first before parsing the links? That Helped !! Thanks alot ! Link to comment https://forums.phpfreaks.com/topic/50805-detect-rss-feeds-on-page/#findComment-249838 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.