Home > php教程 > PHP源码 > 查看某个网址是否被百度收录

查看某个网址是否被百度收录

PHP中文网
Release: 2016-05-25 17:05:59
Original
1638 people have browsed it

php代码

<?php
function checkBaidu($url){
$url=&#39;http://www.baidu.com/s?wd=&#39;.$url;
 
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$rs=curl_exec($curl);
curl_close($curl);
 
$arr=parse_url($url);
 
if(strpos($arr[&#39;query&#39;],&#39;http://&#39;)){
$arr[&#39;query&#39;]=str_replace(&#39;http://&#39;,&#39;&#39;,str_replace(&#39;wd=&#39;,&#39;&#39;,$arr[&#39;query&#39;]));
}else{
$arr[&#39;query&#39;]=str_replace(&#39;wd=&#39;,&#39;&#39;,$arr[&#39;query&#39;]);
}
 
if(strpos($arr[&#39;query&#39;],&#39;?&#39;)){
$str=strstr($arr[&#39;query&#39;],&#39;?&#39;);
$arr[&#39;query&#39;]=str_replace($str,&#39;&#39;,$arr[&#39;query&#39;]);
}
 
if(strpos($arr[&#39;query&#39;],&#39;/&#39;)){
$narr=explode(&#39;/&#39;,$arr[&#39;query&#39;]);
$arr[&#39;query&#39;]=$narr[0];
}
 
if(strpos($rs,&#39;<b>&#39;.$arr[&#39;query&#39;].&#39;</b>&#39;)){
return 1;
}else{
return 0;
}
}
 
echo checkBaidu(&#39;http://www.phpsblogs.com/archives/category/javascript&#39;);
?>
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template