百度需要提交xml和txt格式的
xml格式我在之前的文章写过,txt格式如图:
它的格式就是单行一个网站不能有别的。每个Sitemap.txt文件可以添加的最多网址数目是50000个,如果多于这个数目的,可以再新开一个文件
核心 代码:
//TXT string sitemaptxtname = "sitemap.txt"; string sitemapTxTFileFullNamePath = string.Format(sitemapPath + "/{0}", sitemaptxtname); FileStream fs = new FileStream(sitemapTxTFileFullNamePath, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8); sw.BaseStream.Seek(0, SeekOrigin.End); sw.WriteLine("https://www.yadinghao.com"); sw.Flush(); sw.Close();
按照你自己的 业务写就可以了