通过访问动态php文件。把地图生成保存到静态xml文件
<?php for ($i = 1; $i <= 13; $i++) { $content = file_get_contents("https://www.xxx.com/sitemap/baidu?index=$i"); $c = substr_count($content, '<url>'); if ($c > 1) { //创建存放xml的文件夹 $fp = fopen("pc_sitemap/site$i.xml", "w+"); fwrite($fp, $content); fclose($fp); } } for ($i = 0; $i <= 13; $i++) { $content = file_get_contents("https://m.xxx.com/sitemap/baidu?index=$i"); $c = substr_count($content, '<url>'); if ($c > 1) { //创建存放xml的文件夹 $fp = fopen("wap_sitemap/site$i.xml", "w+"); fwrite($fp, $content); fclose($fp); } }