织梦dedecms程序百度主动推送php代码,文章自动推送到百度

随着百度生态环境及算法改变,内容质量对于搜索引擎来说越来越重要了,那么信息的实时传达到蜘蛛抓取是每位站长必须做到的事情了,链接提交工具是网站主动向百度搜索推送数据的工具,工具可缩短爬虫发现网站链接时间,网站时效性内容建议使用链接提交工具,实时向搜索推送数据。本工具可加快爬虫抓取速度,无法解决网站内容是否收录问题。

站长工具百度度推送分为**“自动提交”和“手动提交”**,手动提交是最简单直接的方式,然而也是最繁琐的方法,所以最受用户喜爱的推送方式当然是自动提交,而自动提交又分为了“主动推送(实时)”、“自动推送”和“sitemap”三种方式,后两种相对比较简单,而第一种相对设置要稍微复杂一点,现在结合本人自己的情况说一说第一种。

使用主动推送功能会达到怎样效果:
及时发现:可以缩短百度爬虫发现您站点新链接的时间,使新发布的页面可以在第一时间被百度收录。
保护原创:对于网站的最新原创内容,使用主动推送功能可以快速通知到百度,使内容可以在转发之前被百度发现
织梦百度php主动推送代码示例:
建议先在命名建立文件为baiduxz_news.php 放在跟目录下

<?php require_once ("include/common.inc.php"); require_once "include/arc.partview.class.php"; require_once('include/charset.func.php'); $year = date("Y"); $month = date("m"); $day = date("d"); $dayBegin = mktime(0,0,0,$month,$day,$year);//当天开始时间戳 $dayEnd = mktime(23,59,59,$month,$day,$year);//当天结束时间戳 $query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin.""; //这里dede换成你们自己的表前缀 $urls=""; $dsql->Execute('arch.id,types.typedir',$query); while($row = $dsql->GetArray('arch.id,types.typedir')) { $urls.="http://www.xiuzhanwang.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; //将上边的http://www.xxx.com 换成你的网址 } $urls=substr($urls,0,-1); $urls = explode(",",$urls); $api = 'http://data.zz.baidu.com/urls?site=www.xxx.com&token=VtDwNoCne61ZfPRzh'; // 前边的site换成自己的site xxx换成自己的密钥 $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode(" ", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); $result = curl_exec($ch); echo $result.count($urls); ?>

更新文档后,浏览器访问执行PHP推送该文件:
如:http://www.xxx.com/baiduxz_news.php 如果返回代码是:
{“remain”:4999998, “success”:2, “not_same_site”:[],“not_valid”:[]}

历史数据,百度PHP推送代码:

<?php require_once ("include/common.inc.php"); require_once "include/arc.partview.class.php"; require_once('include/charset.func.php'); $year = date("Y"); $month = date("m"); $day = date("d"); $dayBegin = mktime(0,0,0,7,1,2015);//网站开始运行时间戳 $dayEnd = mktime(23,59,59,$month,$day,$year);//当天结束时间戳 $query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin.""; //echo $query; $urls=""; $dsql->Execute('arch.id,types.typedir',$query); while($row = $dsql->GetArray('arch.id,types.typedir')) { $urls.="https://m.xxx.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; //将上边的https://m.xxx.com换成你的网址 } $urls=substr($urls,0,-1); $urls = explode(",",$urls); $api = 'http://data.zz.baidu.com/urls?appid=XXXXXXXXXX&token=xxxxxxxxxxxxx&type=batch';// 前边的熊掌号ID和密钥换成自己 $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 $result; ?>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值