您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

将百度搜索结果链接转为实际链接

2024/4/13 22:32:29发布15次查看
最近百度动作挺大的,搜索算法频繁调整。刚才在分析本站百度收录情况的时候又发现百度的搜索结果连接竟然也变了,想必这么做是对付360恶意抓取百度的搜索结果的吧。没办法,百度变了,俺这收录分析工具也得跟着变一变了,总得将这奇长无比的链接转为正常的链接才行吧!
研究了一下,发现还是可以转变的。
function getrealurl($url){
$header=get_headers($url,1);
if (strpos($header[0],'301')||strpos($header[0],'302')){
if(is_array($header['location'])){
return $header['location'][count($header['location'])-1];
}else{
return $header['location'];
}
}else{
return $url;
}
}例如下面这个例子: header('content-type:text/html;charset=utf-8');
function getrealurl($url){
$header=get_headers($url,1);
if (strpos($header[0],'301')||strpos($header[0],'302')){
if(is_array($header['location'])){
return $header['location'][count($header['location'])-1];
}else{
return $header['location'];
}
}else{
return $url;
}
}
$url='http://www.baidu.com/link?url=nuq4redikrtchpwqqxjptc_gsleurk6bb6wmcmzqalhes2luiv98oaikzjvjz8xx';
$url=getrealurl($url);
echo '真实的url为:'.$url;
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product