Home > Backend Development > PHP Tutorial > PHP check whether the page is indexed by Baidu_php tips

PHP check whether the page is indexed by Baidu_php tips

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 20:05:44
Original
2177 people have browsed it

Recently, it is necessary to detect which pages in the website are not indexed by 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; 
 } 
} 
Copy after login

The meaning is very simple. For example, if you need to check whether http://www.jb51.net/article/74039.htm is included, you only need:
checkBaiduInclude(http://www.jb51.net/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.

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template