summed up a PHP to get all the links in the page function, the function code is as follows:
/*
*php get all the links in the page
*/
function Getpagelink ($url) {
Set_time_limit (0);
$html =file_get_contents ($url);
Preg_match_all ("/]+s*") href= ([\ "| ']?) ([^\ "' >\s]+") ([\"|']?) /ies ", $html, $out);
$arrLink = $out [3];
$arrUrl =parse_url ($url);
$dir = ";
if (Isset ($arrUrl [' path ']) &&!empty ($arrUrl [' path ']) {
$dir =str_replace ("\ \", "/", $dir =dirname ($arrUrl [' path ')]);
if ($dir = = "/") {
$dir = "";
}
}
if (Is_array ($arrLink) &&count ($arrLink) >0) {
$arrLink =array_unique ($arrLink);
foreach ($arrLink as $key = = $val) {
$val =strtolower ($val);
if (Preg_match ('/^#*$/isu ', $val)) {
Unset ($arrLink [$key]);
}elseif (Preg_match ('/^\//isu ', $val)) {
$arrLink [$key]= ' http://'. $ARRURL [' Host ']. $val;
}elseif (Preg_match ('/^javascript/isu ', $val)) {
Unset ($arrLink [$key]);
}elseif (Preg_match ('/^mailto:/isu ', $val)) {
Unset ($arrLink [$key]);
}elseif (!preg_match ('/^\//isu ', $val) &&strpos ($val, '/http ') ===false) {
$arrLink [$key]= ' http://'. $ARRURL [' Host ']. $dir. '/'. $val;
}
}
}
Sort ($arrLink);
return $arrLink;
}
The function uses the following:
$links =getpagelink (' http://www.scutephp.com ');
echo "";
Print_r ($links);