php 获取网页外部链接正则表达式...
时间:2010-08-13 来源:linwins
preg_match_all("/<a(.*?)href=(.*?)</a>/i",$webContent,$link);
$urls =array();
foreach($link[0] as $value)
{
if(strstr($value,'http') )
{
if(strstr($value, $ex[3]) || strstr( $value,$ex[0]) || strstr($value,$ex[1]) || strstr($value,$ex[2]))
{
continue;
}
else
{
preg_match_all("/hrefs*=s*(['"]?)(.*?)\1/is", $value, $vlink);
$urls[] = $vlink[2];
}
}
}
$strUrl = deleteEmptyArray( $urls);
function deleteEmptyArray( $val )
{
$links ='';
if( is_array( $val ) )
{
foreach( $val as $v =>$_v)
{
if( !empty( $_v[0] ) )
{
$links .=$_v[0].'|';
}
}
return substr($links,0,-1);
}
else
{
return false;
}
}