署理加盟 2020全新署理方案 挣钱+省钱左右开弓,独立途径,丰盛赢利!

您现在的方位: 188bet网 > 织梦大学 > 运用教程 >

织梦程序百度php自动推送代码,亲测可用!

来历:本站原创 发布时刻:2019-04-14 10:59:27热度:我要谈论(0

免费下载,无需注册无需充值

跟着百度生态环境及算法改动,内容质量关于查找引擎来说越来越重要了,那么信息的实时传到达蜘蛛抓取是每位站长有必要做到的工作了,链接提交东西是网站自意向百度查找推送数据的东西,东西可缩短爬虫发现网站链接时刻,网站时效性内容主张运用链接提交东西,实时向查找推送数据。本东西可加快爬虫抓取速度,无法处理网站内容是否录入问题。

站长东西百度度推送分为“自动提交”和“手动提交”,手动提交是最简略直接的办法,但是也是最繁琐的办法,所以最受用户喜欢的推送办法当然是自动提交,而自动提交又分为了“自动推送(实时)”、“自动推送”和“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.ms88kzm.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; 

 //将上边的http://www.ms88kzm.com 换成你的网址

}

$urls=substr($urls,0,-1);

$urls = explode(",",$urls);

$api = 'http://data.zz.baidu.com/urls?site=www.ms88kzm.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.ms88kzm.com/baiduxz_news.php 假如回来代码是:

{"remain":4999998, "success":2, "not_same_site":[],"not_valid":[]}

织梦百度php自动推送代码示例,亲试肯定成功!

历史数据,百度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.ms88kzm.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";

//将上边的https://m.ms88kzm.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;

?>

概况能够检查教程:DEDECMS织梦程序完成熊掌号API提交接口推送(PHP推送)

 

转载请注明来历网址:https://www.ms88kzm.com/dedecms_jq/1641.html

    宣布谈论

    谈论列表(条)