使用php编写百度sitemap

来源:互联网 发布:淘宝店怎么医疗器械 编辑:程序博客网 时间:2024/04/30 00:34
 public function  pc()    {//        $table_name = get_sites_table_name($this->site['id']);        $datas = get_site_data($this->site['id'], 1, 1000);//这里是获取http://www.renti199.com的站点内容        $datas = $datas['data'];        echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>        ");        echo('<urlset    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9       http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">');        foreach ($datas as $k => $v) {            $url = "http://".$this->site['domain'] . get_show_url($v);            echo '            <url>             <loc>' . $url . '</loc>             <priority>0.5</priority>             <lastmod>' . date("Y-m-d", time()) . '</lastmod>             <changefreq>daily</changefreq>            </url>            ';        }        echo "</urlset>";    }