Home  >  Article  >  Backend Development  >  php检查页面是否被百度收录,php检查页面收录_PHP教程

php检查页面是否被百度收录,php检查页面收录_PHP教程

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

php检查页面是否被百度收录,php检查页面收录

最近需要检测网站内哪些页面没有被百度搜索引擎收录从而进行相关的调整。由于使用site命令一条条的去看实在是看不过来,就想到了使用php程序来批量处理一下,研究了一下,发现其实很简单,下面就将使用php实现的检测页面是否被百度收录的功能分享一下。
下面是具体代码:

<&#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; 
 } 
} 

意思很简单了,比如需要检测 http://www.bkjia.com/article/74039.htm 这个网址是否被收录,则只需要:
checkBaiduInclude(http://www.bkjia.com/article/74039.htm‘);
反回结果为1为收录。为0则没有收录。

这篇文章就介绍到这,网站中还有相关文章供大家学习,希望对大家的学习有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1065570.htmlTechArticlephp检查页面是否被百度收录,php检查页面收录 最近需要检测网站内哪些页面没有被百度搜索引擎收录从而进行相关的调整。由于使用 site命...
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