emlog百度自动收录代码

首先找到模板文件中的 module.php。在合适的位置插入下面代码:

<?php
//判断内容页是否百度收录
function baidu($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;
  }   
     }
  function checkbaidu($id){
  $url=Url::log($id);
  if(baidu($url)==1){
   echo "百度已收录";
  } else {
   if (ROLE == 'admin' || ROLE == 'writer') {
    $urls = array(
      $url,
  );
  $api = 'http://data.zz.baidu.com/urls?site=你自己的域名&token=你自己的token值';
  $ch = curl_init();
  $options =  array(
     CURLOPT_URL => $api,
     CURLOPT_POST => true,
     CURLOPT_RETURNTRANSFER => true,
     CURLOPT_POSTFIELDS => implode("\n", $urls),
     CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),);
  curl_setopt_array($ch, $options);
  $result = curl_exec($ch);
  echo 'success';
   }
     echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\">已自动提交度娘等待收录</a>";
  }
}
?>
没有token值的朋友,可以去百度站长平台注册一个。官网“<a href="https://ziyuan.baidu.com/">https://ziyuan.baidu.com/</a>”。

七彩云博客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:emlog百度自动收录代码

您必须 登录 才能发表评论!

(7)个小伙伴在吐槽
  1. Drug And Alcohol Rehab Near Me http://aaa-rehab.com Drug Rehab Centers Near Me Program Drug Rehab https://articlesforwebsite.com/profile/albertsr/about
    Intensive Outpatient Alcohol Treatment2020-04-01 18:11 Windows 7 | Chrome 66.0.3359.181
  2. Suboxone Clinic Near Me Free http://aaa-rehab.com Drug Rehab 30 Day Inpatient Rehab https://film-hd.org/user/iviva/
    Long Term Inpatient Drug Rehab2020-04-01 02:19 Windows 10 | Chrome 68.0.3440.106
  3. Free Drug And Alcohol Rehabilitation Centers http://aaa-rehab.com Alcohol Rehab Near Me Alcohol Rehab For Professionals http://mp3-muzik.ru/user/rehabcenters/
    Luxury Alcohol Rehab2020-03-31 10:22 Windows 10 | Chrome 67.0.3396.87
  4. Free Rehabilitation Centres http://aaa-rehab.com Drug Rehab Drug Alcohol Rehab http://im-40.4host.kz/user/iviva/
    Drug Abuse Rehab2020-03-30 18:09 Windows 7 | Chrome 66.0.3359.181
  5. Free Rehabilitation Centres http://aaa-rehab.com Drug Rehab Drug Alcohol Rehab http://im-40.4host.kz/user/iviva/
    Drug Abuse Rehab2020-03-30 18:08 Windows 7 | Chrome 66.0.3359.181
  6. Meth Rehab Centers Near Me http://aaa-rehab.com Drug Rehab Near Me http://aaa-rehab.com Substance Abuse And Domestic Violence http://aaa-rehab.com
    Drug Rehab For Young Adults2020-03-27 12:24 Windows 7 | Chrome 67.0.3396.87
  7. 中國金銀集團有限公司位于香港干诺道中168-200号信德中心西座2103室,經香港政府批準成立,專註為全球投資者提供專業的網上投資服務,主要經營倫敦金、倫敦銀、實物黃金、人民幣公斤條等業務。http://www.cgsh.hk
    中国金银集团2018-09-07 09:15 未知操作系统 | 未知浏览器