久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php自動(dòng)生成sitemap

      php自動(dòng)生成sitemap

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

      所以我們平時(shí)要有定期更新sitemap的習(xí)慣,生成sitemap的方法有很多,第三方工具抓取生成,自己生成。這里我推薦自己生成sitemap。因?yàn)檫@樣消耗系統(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ù)庫(kù)我使用了最小巧的medooORM模型,非常方便。

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

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