Page 1 of 1

extracting URLs

Posted: Fri Feb 17, 2006 9:46 pm
by xcom923
I was wondering if it was possible to extract all URLs from a file and list them. does anyone have an idea on how to do this. pretty much I need to extract URLs from an RSS feed.

Posted: Fri Feb 17, 2006 10:10 pm
by MinDFreeZ

Code: Select all

<?php 

$page = 0;  
$URL = "http://www.thewebsite.com/thepage";  
$page = @fopen($URL, "r");  
print("Links at $URL<BR>\n");  
print("<UL>\n");  
while(!feof($page)) {  
$line = fgets($page, 255);  
while(eregi("HREF=\"[^\"]*\"", $line, $match)) {  
print("<LI>");  
print($match[0]);  
print("<BR>\n");  
$replace = ereg_replace("\?", "\?", $match[0]);  
$line = ereg_replace($replace, "", $line);  
}  
}  
print("</UL>\n");  
fclose($page);  

?>
... I didn't make this.... but it grabs all the link from a page... and lists them... so it should work for an RSS feed too... probably.
if not, probably a small alteration could be done to make it work.

Posted: Sat Feb 18, 2006 12:13 am
by quocbao
There are many classes for reading RSS on PHPClasses , you can use one of them :)

Posted: Sat Feb 18, 2006 8:37 am
by xcom923
quocbao wrote:There are many classes for reading RSS on PHPClasses , you can use one of them :)
yeah I know that, but RSS was just an example MinDFree's snipet was much more helpfull