xvmqC1Ye - 9天前注册会员;
mbtdr3ev - 14天前注册会员;
3n44fZgo - 34天前注册会员;
73n5lsCR - 48天前注册会员;
NaZ2pUfG - 57天前注册会员;
加入我们(63 )

typecho-判断百度是否收录本文章

有人问起,就写一下吧

把一下代码放在functions.php

//判断内容页是否百度收录,如果你开启了ssl下面的http改成htts

function baidu_record() {
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 

if(checkBaidu($url)==1)
{echo "百度已收录";
}
else
{echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\">百度未收录</a>";}
}
  function checkBaidu($url) { 
    $url = 'http://www.baidu.com/s?wd=' . urlencode($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 -1; 
    } 
}

调用<?php echo baidu_record() ?>

这里以handsome主题为例

把下面的内容放在post.php大约80行,分类下面

<!--百度收录-->
<li><i class="glyphicon glyphicon-globe"></i> <?php echo baidu_record() ?></li>

好啦,教程到此结束

声明:本站原创文章文字版权归本站所有,转载务必注明作者和出处;本站转载文章仅仅代表原作者观点,不代表本站立场,图文版权归原作者所有。如有侵权,请联系我们删除。