每次提交网站链接至百度收录时每一条都要把文章链接复制过去,很麻烦很费事,使用下面的方法配合宝塔计划任务每天准时自动提交网站全站链接省事!
教程
代码
<?phpheader('Content-Type:text/html;charset=utf-8');$xmldata =file_get_contents("https://wuzuhua.cn/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://wuzuhua.cn&token=O4e5NmFo9jv5PrkF';$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;?>
成功示例
效果
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有