随着百度生态环境及算法改变,内容质量对于搜索引擎来说越来越重要了,那么信息的实时传达到蜘蛛抓取是每位站长必须做到的事情了,链接提交工具是网站主动向百度搜索推送数据的工具,工具可缩短爬虫发现网站链接时间,网站时效性内容建议使用链接提交工具,实时向搜索推送数据。本工具可加快爬虫抓取速度,无法解决网站内容是否收录问题。
站长工具百度度推送分为“自动提交”和“手动提交”,手动提交是最简单直接的方式,然而也是最繁琐的方法,所以最受用户喜爱的推送方式当然是自动提交,而自动提交又分为了“主动推送(实时)”、“自动推送”和“sitemap”三种方式,后两种相对比较简单,而第一种相对设置要稍微复杂一点,现在结合本人自己的情况说一说第一种。
及时发现:可以缩短百度爬虫发现您站点新链接的时间,使新发布的页面可以在第一时间被百度收录
保护原创:对于网站的最新原创内容,使用主动推送功能可以快速通知到百度,使内容可以在转发之前被百度发现
建议先在命名建立文件为baiduxz_news.php 放在跟目录下
<?phprequire_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.CUOxin.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; //将上边的http://www.CUOxin.com 换成你的网址}$urls=substr($urls,0,-1);$urls = explode(",",$urls);$api = 'http://data.zz.baidu.com/urls?site=www.CUOxin.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);?> |
如:http://www.CUOxin.com/baiduxz_news.php 如果返回代码是:
{"remain":4999998, "success":2, "not_same_site":[],"not_valid":[]}
<?phprequire_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.CUOxin.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";//将上边的https://m.CUOxin.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("", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),);curl_setopt_array($ch, $options);$result = curl_exec($ch);echo $result;?> |
详情可以查看教程:DEDECMS织梦程序实现熊掌号API提交接口推送(PHP推送)
新闻热点
疑难解答