function parser($link, $level=0) { $contents = file_get_contents($link); $regex = "#(h)[ ]*(r)[ ]*(e)[ ]*(f)[ ]*(=)[ ]*[\"\']{0,1}[\w:/\.?=_ %&\\-+]+[\"\'(/>)(>)]{0,2}#"; preg_match_all($regex, $contents, $out, PREG_SET_ORDER); $regex_external_js = "#(<)[ ]*(s)[ ]*(c)[ ]*(r)[ ]*(i)[ ]*(p)[ ]*(t)[ ]*(t)[ ]*(y)[ ]*(p)[ ]*(e)[ ]*(=)[ ]*[\"\’](t)[ ]*(e)[ ]*(x)[ ]*(t)[ ]*(/)[ ]*(j)[ ]*(a)[ ]*(v)[ ]*(a)[ ]*(s)[ ]*(c)[ ]*(r)[ ]*(i)[ ]*(p)[ ]*(t)[ ]*[\"\']{0,1}[ ]*(s)[ ]*(r)[ ]*(c)[ ]*(=)[ ]*[\w/\.:/-+%&?’=\\_\"\' ]{4,}(>)#"; preg_match_all($regex_external_js, $contents, $matches, PREG_SET_ORDER); for($i=0; $i< sizeof($matches); $i++) echo $matches[$i][0]."\n"; $nr_of_results = sizeof($out); echo "Results ($nr_of_results links found):
"; for($i=0; $i< sizeof($out); $i++) { $out[$i][0] = str_replace("'", "", str_replace(">", "", str_replace("\"", "", str_replace("href=", "", str_replace(' ', '', $out[$i][0]))))); if(strpos($out[$i][0], "http://") === FALSE) $out[$i][0] = $link."".$out[$i][0]; echo ($i+1).". ".$out[$i][0]."
"; } }