DT产品模块批量循环提交百度

   功能需求:DT7.0产品模块批量循环提交百度,让没有收录的内容重新进行抓取,以提高收录。

 

    

  代码如下:

 

    

<?php
/*
百度主动推送三项合一功能
作者:68喜科技
用于:DT7.0 
功能模块:批量循环提交百度
*/
//引入错误显示
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require './common.inc.php'; //引入公用函数
$starid =1;   //初始ID 开始
$limitList=1000; //限制条数
while($starid<120000){
$query = "SELECT itemid FROM {$DT_PRE}sell_5 WHERE  itemid> $starid ORDER BY itemid ASC  LIMIT $limitList";   //查询数据库限制
//推送核心代码
$result = $db->query($query);
$urls="";
$domain="http://www.sdfymj.com/";//域名
while ($r=$db->fetch_array(($result)))
{  
 $linkId = $r['itemid'];  //获取文章ID
 $linkurl ="sell/show-".$linkId.".html";//定义模块URL
//修改域名
$urls.=$domain.$linkurl.",";
//echo "为您推送的URL为:<br/>".$urls."<br/>";
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
//接口推送
//$api = 'mip推送接口';//mip推送
//$bdxzhapi='熊掌号接口';//熊掌号历史推送
$pttsapi='普通推送接口';//普通推送
$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  "百度MIP 推送成功:". $result."<br/>";
 */
 /*
$options =  array(
     CURLOPT_URL => $bdxzhapi,
    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."<br/>";
*/
$options =  array(
     CURLOPT_URL => $pttsapi,
    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."<br/>";
 
 $starid=$starid+2000; //因为每一轮2000条推送
}
 ?>

  

   

posted @ 2020-05-08 16:50  圆柱模板  阅读(334)  评论(6编辑  收藏  举报