<?php $token='http://data.zz.baidu.com/urls?site=www.xxxxx.com&token=6lvko54336DCLR6e';//去百度获取 $xml_string = file_get_contents("https://www.1004619.com/sitemap.xml");//网站地图 $xml_string = trim($xml_string); $xml_object = simplexml_load_string($xml_string); $array=[]; $i=0; foreach ($xml_object->url as $key=>$value){ //$i=500 代表从地图获取500条连接 默认是从第一条开始 if($i===88){ break; } $array['aa']= get_object_vars($value); $url.=$array['aa']['loc']."\n"; $i++; } $urls=explode("\n",$url); $ch = curl_init(); $options = array( CURLOPT_URL => $token, 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; ?>