雷火电竞-中国电竞赛事及体育赛事平台

代理加盟

2023全新代理計(jì)劃,一站式模板建站,銅牌代理低至699元送終身VIP,獨(dú)立代理后臺(tái),自營(yíng)貼牌。

您現(xiàn)在的位置: 麥站網(wǎng) > 織夢(mèng)大學(xué) > 使用教程 >

織夢(mèng)程序百度php主動(dòng)推送代碼,親測(cè)可用!

來(lái)源:本站原創(chuàng) 發(fā)布時(shí)間:2019-04-14 10:59:27熱度:我要評(píng)論(0

麥站模板建站平臺(tái)(10年經(jīng)驗(yàn)),服務(wù)數(shù)萬(wàn)家企業(yè),固定透明報(bào)價(jià)。域名注冊(cè)、主機(jī)/服務(wù)器、網(wǎng)站源碼一站式服務(wù)。實(shí)體公司,專(zhuān)業(yè)團(tuán)隊(duì),值得選擇!超過(guò)1000套模板已登記版權(quán),合規(guī)合法建站,規(guī)避版權(quán)風(fēng)險(xiǎn)!【點(diǎn)擊獲取方案】

隨著百度生態(tài)環(huán)境及算法改變,內(nèi)容質(zhì)量對(duì)于搜索引擎來(lái)說(shuō)越來(lái)越重要了,那么信息的實(shí)時(shí)傳達(dá)到蜘蛛抓取是每位站長(zhǎng)必須做到的事情了,鏈接提交工具是網(wǎng)站主動(dòng)向百度搜索推送數(shù)據(jù)的工具,工具可縮短爬蟲(chóng)發(fā)現(xiàn)網(wǎng)站鏈接時(shí)間,網(wǎng)站時(shí)效性?xún)?nèi)容建議使用鏈接提交工具,實(shí)時(shí)向搜索推送數(shù)據(jù)。本工具可加快爬蟲(chóng)抓取速度,無(wú)法解決網(wǎng)站內(nèi)容是否收錄問(wèn)題。

站長(zhǎng)工具百度度推送分為“自動(dòng)提交”和“手動(dòng)提交”,手動(dòng)提交是最簡(jiǎn)單直接的方式,然而也是最繁瑣的方法,所以最受用戶(hù)喜愛(ài)的推送方式當(dāng)然是自動(dòng)提交,而自動(dòng)提交又分為了“主動(dòng)推送(實(shí)時(shí))”、“自動(dòng)推送”和“sitemap”三種方式,后兩種相對(duì)比較簡(jiǎn)單,而第一種相對(duì)設(shè)置要稍微復(fù)雜一點(diǎn),現(xiàn)在結(jié)合本人自己的情況說(shuō)一說(shuō)第一種。

使用主動(dòng)推送功能會(huì)達(dá)到怎樣效果:

及時(shí)發(fā)現(xiàn):可以縮短百度爬蟲(chóng)發(fā)現(xiàn)您站點(diǎn)新鏈接的時(shí)間,使新發(fā)布的頁(yè)面可以在第一時(shí)間被百度收錄

保護(hù)原創(chuàng):對(duì)于網(wǎng)站的最新原創(chuàng)內(nèi)容,使用主動(dòng)推送功能可以快速通知到百度,使內(nèi)容可以在轉(zhuǎn)發(fā)之前被百度發(fā)現(xiàn)

織夢(mèng)百度php主動(dòng)推送代碼示例:

建議先在命名建立文件為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);//當(dāng)天開(kāi)始時(shí)間戳

$dayEnd = mktime(23,59,59,$month,$day,$year);//當(dāng)天結(jié)束時(shí)間戳

$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.jygsgssxh.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; 

 //將上邊的http://www.jygsgssxh.com 換成你的網(wǎng)址

}

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

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

$api = 'http://data.zz.baidu.com/urls?site=www.jygsgssxh.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);

?>

更新文檔后,瀏覽器訪(fǎng)問(wèn)執(zhí)行PHP推送該文件:

如:http://www.jygsgssxh.com/baiduxz_news.php 如果返回代碼是:

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

織夢(mèng)百度php主動(dòng)推送代碼示例,親試絕對(duì)成功!

歷史數(shù)據(jù),百度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);//網(wǎng)站開(kāi)始運(yùn)行時(shí)間戳

$dayEnd = mktime(23,59,59,$month,$day,$year);//當(dāng)天結(jié)束時(shí)間戳 

$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.xiuzhanwang.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";

//將上邊的https://m.xiuzhanwang.com換成你的網(wǎng)址

}

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

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

 

$api = 'http://data.zz.baidu.com/urls?appid=XXXXXXXXXX&token=xxxxxxxxxxxxx&type=batch';// 前邊的熊掌號(hào)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織夢(mèng)程序?qū)崿F(xiàn)熊掌號(hào)API提交接口推送(PHP推送)

 

    轉(zhuǎn)載請(qǐng)注明來(lái)源網(wǎng)址:http://www.jygsgssxh.com/dedecms_jq/1641.html

    發(fā)表評(píng)論

    評(píng)論列表(條)

       
      QQ在線(xiàn)咨詢(xún)
      VIP限時(shí)特惠