批量文章推送给百度API的代码

2022-03-29  栏目:网络技术   投稿:八羊广告

摘要:批量文章推送给百度API的代码,涉及到时间戳日期转换……

最近百度收录很不稳定,而且提交了也不收录一直找不到原因所在。检查了提交代码发现提交的文章都是无法打开的,所以出现了问题。

image.png

$limit = 2000; //百度一次性推送最多2000条记录,所以限制推送数量为2000

$query = "SELECT arch.id,arch.senddate,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate>0 and types.topid=2 ORDER BY pubdate DESC LIMIT $limit"; 

$urls="";


$dsql->Execute('arch.id,arch.senddate,types.typedir',$query);

while($row = $dsql->GetArray('arch.id,arch.senddate,types.typedir'))

{


//echo date('md',$row[senddate]);

//exit();


 $urls.="https://www.8y-ad.com".str_replace("{cmspath}","",$row['typedir'])."/".date('Y',$row[senddate])."/".date('md',$row[senddate])."/".$row[id].".html".","; 


}


//exit();

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

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

$api = 'http://data.zz.baidu.com/urls?site=www.8y-ad.com&token=g9999999991FN8Va'; // 前边的api换成自己的推送 API

$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.count($urls);


echo $result;



echo $urls;



文章分享二维码:


友情提示:信息若有侵犯请联系删除,下载资源若失效请联系微信haracle解决。装黑客下载 | LUT包下载