新手搭建网站还是有很多事情要做的,例如网站所有链接肯定是要每天提交给百度的,但是一条条的提交肯定费事,不过大家使用下面的php代码即可搞定,配合宝塔自动提交就可以了!
[hidecontent type=”reply”]
<?php
header('Content-Type:text/html;charset=utf-8');
$xmldata =file_get_contents("https://sckj.cc/wp-sitemap.xml");
$xmlstring = simplexml_load_string($xmldata,'SimpleXMLElement',LIBXML_NOCDATA);
$value_array = json_decode(json_encode($xmlstring),true);
$url = [];
for ($i =0;$i < count($value_array['url']);$i++){
echo $value_array['url'][$i]['loc']."<br/>";
$url[]= $value_array['url'][$i]['loc'];
}
$api ='http://data.zz.baidu.com/urls?site=https://sckj.cc&token=zMl3AlGyW15GVPN6';
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode("\n",$url),
CURLOPT_HTTPHEADER => array('Content-Type:text/plain'),
);
curl_setopt_array($ch, $options);
$result =curl_exec($ch);
echo $result;?>
[/hidecontent]