久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php自動生成sitemap

      php自動生成sitemap

      網(wǎng)站的sitemap是爬蟲抓取的主要地方,提交了sitemap的url,爬蟲會優(yōu)先抓取。

      所以我們平時要有定期更新sitemap的習慣,生成sitemap的方法有很多,第三方工具抓取生成,自己生成。這里我推薦自己生成sitemap。因為這樣消耗系統(tǒng)資源最少。

      代碼如下:

      include_once Root_Path . "/vendor/autoload.php"; use MedooMedoo; $db = new Medoo([ 'database_type' => 'mysql', 'database_name' => 'menghuiguli', 'server' => 'localhost', 'username' => 'root', 'password' => 'root', ]); $str = "<ul>"; $articles = $db->select('article',"*"); foreach ($articles as $k => $v) { $str .= '<li> <div class="T1"><a href="https://www.80shihua.com/archives/'.$v['id'].'" title="'.$v['name'].'">'.$v['name'].'</a></div> <div class="T2">2019-02-02T10:16:23+08:00</div> <div class="T3">monthly</div> <div class="T4">0.5</div> </li>'; } $str .= '</ul>'; file_put_contents('/sitemap.html', $str);

      其中數(shù)據(jù)庫我使用了最小巧的medooORM模型,非常方便。

      我們只要查出相關(guān)文章,然后對應循環(huán)生成sitemap即可。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號