织梦dedecms5.7百度主动推送(实时),发布文章时主动提交到百度,可加快百度蜘蛛抓取速度

织梦百度主动推送方法一

打开/dede/article_add.php,搜索

ClearMyAddon($arcID, $title);

大约在260行,在它上面添加

else{
$urls[]='http://'.$_SERVER['HTTP_HOST'].$artUrl;  
$api = 'http://data.zz.baidu.com/urls?site=你的域名&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);
}

注意,红色代码,是你在百度站长后台获取的接口调用地址。

20180105212544

搜索

<a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已发布文章管理</u></a>

在它下面添加:

<a href=''><u>百度提交返回".$result."</u></a>
&nbsp;&nbsp;

这个是添加文章后返回是不是成功提交了。

百度主动推送

 

上图就是表示1条提交成功,还剩下4999998条可提交。

下图的这个站是最新几天才添加的这个功能。文章内容也是每天更新一到两篇。一般推送后过一两天才能看到效果.

 

 

20180105211134

织梦百度主动推送方法二

1、后台-系统-基本参数,添加新变量,

 

变量名称:cfg_baidu_push

变量值:里面填写你从百度获取的需要推送域名的参数:http://data.zz.baidu.com/urls?site=https://www.441516.com&token=Wgn313aE0GAxfuaI,保存,如果变量值未填写或者为空将不推送。

参数说明:百度推送接口

2、打开 /dede/inc/inc_archives_functions.php 在文件最末尾插入下面代码

/**
 * 百度主动推送
 */
function baidu_push($id="",$qstr="")
{
	global $cfg_multi_site,$cfg_basehost,$cfg_baidu_push;
	if(!empty($id) && !empty($cfg_baidu_push))
	{
		if( !empty($id) && empty($qstr) ) $qstr = $id;
		if($qstr=='')
		{
			exit();
		}
		$qstrs = explode('`',$qstr);
		$cfg_domain = $cfg_multi_site == 'N' ? $cfg_basehost : '';
		$urls = array();
		$i = 0;
		foreach($qstrs as $aid)
		{
			$i++;
			$arcrow = GetOneArchive($aid);
			$url = $cfg_domain.$arcrow['arcurl'];
			$urls[] = $url;
			$artlist .= $url."<br />";
		}
		if($i>1) $artlist = "";
		if(!empty($urls)){
			$ch = curl_init();
			$options =  array(
				CURLOPT_URL => trim($cfg_baidu_push),
				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);
			curl_close($ch);
			$result = json_decode($result, true);
			if(isset($result['success'])){
				$not_same_site = isset($result['not_same_site'][0]) ? " <font style='color:#f00;'>推送链接与百度绑定站点不一致</font> " : "";
				$not_valid = isset($result['not_valid'][0]) ? " <font style='color:#f00;'>推送链接不合法</font> " : "";
				return $not_same_site . $not_valid . '百度主动推送成功 '.$result['success'].' 条!当天剩余 '.$result['remain'].' 条可推送!'.$artlist;
			}else{
				return '百度主动推送失败,错误码:'.$result['error'].'<a href="https://ziyuan.baidu.com/college/courseinfo?id=267&page=2#h2_article_title12" target="_blank">详情</a>';
			}
		}
		return "没有数据被推送!";
	}
}

打开后台/dede/article_add.php搜索

//返回成功信息

在它上面加入

if(!empty($cfg_baidu_push))
{
	$backurl .= "<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".baidu_push($arcID)."</p>";
}

继续搜索

line-height:36px;height:36px

修改为

line-height:36px;

此教程为文章模模型的推送,如你有软件,图集模型或者其他模型,请参照上面内容自行修改相应模型添加内容。

方法二效果

完毕!

还有一个插件是不光可以推送到百度,还可以推送到神马,不过是收费插件,详细介绍查看下面页面!

织梦批量向百度及神马搜索引擎自动批量推送文章插件

 

 

THE END