php检查页面是否被百度收录,php百度收录查询代码,可整合到后台使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yw8886484/article/details/87898914

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

<?php
$cxurl="www.meiye5.com/html/n212.html";
function okBaidu($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,'提交网址')){
	 echo "已收录";
 }else{
	 echo "未收录";
 }
}
echo okBaidu($cxurl);
?>

html查询页面:

<p>测试一下吧,复制一个网址到文本框:<span id="baidushoulu"><span style="color:#ff0000;font-weight:900;">× 未收录</span><a target="_blank" style="margin-left:10px;color:#6d6d6d;" href="https://www.baidu.com/s?wd=www.nongyejing.com/11,html">[去百度查看结果]</a></span></p>

<form id="form"><input onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}" id="textfields" name="baidushoulu" autocomplete="off" style="width:70%;margin-right:3%;"><a onclick="demo()" style="color: rgb(255, 255, 255); text-decoration: none; cursor: pointer; font-family: 微软雅黑; display: inline-block; width: 140px; text-align: center; background:rgb(0, 124, 212); line-height: 30px; border-radius: 10px; position: relative; margin-right: 20px;">查询</a></form>

JS:

<script type="text/javascript">
function baidushoulu(){
    $.ajax({
        type: "POST",
        url: "/php/baidushoulu.php",//提交到后台文件
        data: $('#form').serialize(),//表单传值
        success: function(data) {        
            $("#baidushoulu").html(data);//以html的形式显示在指定id的元素里
        }
    });
    return false;
}
function demo(){
    var nv = document.getElementById("baidushoulu");
    nv.innerHTML="正在查询...";setTimeout('baidushoulu()',500);
}
</script>

来源:企业号

猜你喜欢

转载自blog.csdn.net/yw8886484/article/details/87898914