如 <a href="../../content.html">详情</a>含相对路径
collection.class.php
get_html(){
$url = real_url($ur);l
...
}
url_check(){
...
return real_url($ur);
}
get_url_lists(){
...
$out[2] = array_unique($out[2]);//会导致即便链接地址不同,但<a></a>之间内容相同的链接仅仅采集一项
...
}
/**
* 带../的url转为不带../
* @param string $url
* @return string
*/
function reald_url($url){
if($r_post = strripos($url,'../')){
$url_suf = substr($url, $r_post+3);
$url_pre = substr($url, 0, strpos($url, '../'));
$num = substr_count($url,'../');
$url_pre = strrev(preg_replace('/([a-z0-9\-]+\/)/', '', strrev($url_pre),$num));
$url = $url_pre.$url_suf;
}
return $url;
}