用shell快速生成xml格式sitemap【亲测好用!】

seofangfa shell学习笔记22,690阅读模式

用shell快速生成xml格式的sitemap地图文件,中小型网站适用。在本次案例中,生成12053条URL的sitemap文件,仅用时4.3秒!shell代码如下:

cat sitemap.txt|awk 'BEGIN{print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset>"}{print "<url>\n<loc>"$0"</loc>\n<lastmod>2014-07-18</lastmod>\n<changefreq>always</changefreq>\n</url>"}END{print "</urlset>"}'

其中sitemap.txt是网站所有URL的集合,<lastmod>后面的日期,需要修改为你当时生成sitemap文件时的日期,今天是2014年7月18日,所以我写的是这个。

其实用txt格式的sitemap百度也是认可的,为了体现shell功能强大之处,我才在此非得把txt格式的折腾成xml格式的!!!sitemap.txt内容如下图,总共有12053条URL。

用shell快速生成xml格式sitemap【亲测好用!】-图片1

最终效果及生成速度,总共12053条URL,生成xml格式的sitemap,仅用时4.3秒!速度还是相当快的!

用shell快速生成xml格式sitemap【亲测好用!】-图片2

文章末尾固定信息

weinxin
我的微信
我的微信
微信扫一扫
 
seofangfa
  • 本文由 seofangfa 发表于 2014年7月18日00:37:51
  • 转载请务必保留本文链接:https://wp.fangfa.me/shell/shell-xml-sitemap.html
评论  2  访客  0
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证