Recently, it is necessary to detect which pages in the website are not included in the Baidu search engine and make relevant adjustments. Since I couldn’t see it clearly by using the site command one by one, I thought of using a PHP program to batch process it. After some research, I found that it is actually very simple. Here is the detection page implemented using PHP Share whether the function is included in Baidu.
The following is the specific code:
<?php /* * 检测网页是否被百度收录,返回1则表示收录 返回0表示没有收录 * @ param string $url 待检测的网址 */ function checkBaiduInclude($url){ $url='http://www.baidu.com/s?wd='.$url; $curl=curl_init(); curl_setopt($curl,CURLOPT_URL,$url); curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); $rs=curl_exec($curl); curl_close($curl); if(!strpos($rs,'抱歉,没有找到')){ return 1; }else{ return 0; } }
The meaning is very simple. For example, if you need to check whether the URL http://www.bkjia.com/article/74039.htm is included, you only need:
checkBaiduInclude(http://www.bkjia.com/article/74039.htm‘);
The return result is 1 for inclusion. If it is 0, it is not included.
That’s it for this article. There are also related articles on the website for everyone to learn. I hope it will be helpful to everyone’s study.