Home > php教程 > php手册 > php程序检测页面是否被百度收录

php程序检测页面是否被百度收录

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-21 08:49:09
Original
1524 people have browsed it

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

下面是具体代码:

<?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;
    }   
}
Copy after login

意思很简单了,比如需要检测 http://www.Alixixi.com/javascript-function/833.html 这个网址是否被收录,则只需要:

checkBaiduInclude('http://www.Alixixi.com/javascript-function/833.html');
Copy after login

结果自己去看吧。



Related labels:
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 Issues
curl simulated login
From 1970-01-01 08:00:00
0
0
0
Convert cURL command line to PHP cURL code
From 1970-01-01 08:00:00
0
0
0
Convert command line cURL to PHP cURL
From 1970-01-01 08:00:00
0
0
0
How to set boolean value true in php curl
From 1970-01-01 08:00:00
0
0
0
Please tell me, php curl request page shows blank
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template