Home  >  Article  >  Backend Development  >  PHP checks whether the page is included in Baidu, PHP checks whether the page is included_PHP tutorial

PHP checks whether the page is included in Baidu, PHP checks whether the page is included_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:06:27925browse

php checks whether the page is included in Baidu, php checks whether the page is included

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:

<&#63;php 
/* 
* 检测网页是否被百度收录,返回1则表示收录 返回0表示没有收录 
* @ param string $url 待检测的网址 
*/ 
function checkBaiduInclude($url){ 
 $url='http://www.baidu.com/s&#63;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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1065570.htmlTechArticlephp check whether the page is included in Baidu, php check page included Recently, it is necessary to detect which pages in the website are not indexed by Baidu search engine included to make relevant adjustments. Due to the use of site command...
Statement:
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