百度一般都是通过站的sitemap.xml来进行页面爬取和索引,所以你必须在网站的根目录下生成一个sitemap.xml文件,让百度知道你的站点更新的啥,sitemap.xml的地址可以放到 robots.txt 文件中。
根目录 robots.txt如下,这里定义了user-agent,表示容许哪些爬虫来爬取,*表示所有,百度叫Baiduspider,谷歌叫Googlebot,Disallow表示哪些页面和目录不容许爬取。注意:sitemap 谷歌为xml格式,百度为html格式
User-agent: *那么sitemap怎么写呢
Disallow:
Disallow: /admin/
Sitemap: http://domain.com/sitemap.xml
<?xml version="1.0" encoding="UTF-8" ?>loc就是需要百度检索的网页url;
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">
<url>
<loc>https://www.domian.com/</loc>
<mobile:mobile type="pc,mobile" />
<priority>0.8</priority>
<lastmod>2021-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.domian.com/blog/1.html</loc>
<mobile:mobile type="pc,mobile" />
<priority>0.8</priority>
<lastmod>2021-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.domian.com/blog/</loc>
<mobile:mobile type="pc,mobile" />
<priority>0.8</priority>
<lastmod>2021-05-14</lastmod>
<changefreq>weekly</changefreq>
</url>
</urlset>
mobile表示是否支持手机和pc的自适应显示;
priority用来指定此链接相对于其他链接的优先权比值,取值范围为0.0~1.0之间。值越大,表示此链接的优先权就越高;
lastmod表示上次修改时间;
changefreq表示修改频率,可以填写:“always”(经常) 、“hourly”(每时)、“daily”(每天)、“weekly”(每周)、“monthly”(每月)、“yearly”(每年)。像首页就可以用“always”;对于很久前的链接或不再更新内容的链接就可以使用“yearly”
网友回复
python如何实现torrent的服务端进行文件分发p2p下载?
如何在浏览器中录制摄像头和麦克风数据为mp4视频保存下载本地?
go如何编写一个类似docker的linux的虚拟容器?
python如何写一个bittorrent的种子下载客户端?
ai能通过看一个网页的交互过程视频自主模仿复制网页编写代码吗?
ai先写功能代码通过chrome mcp来进行测试功能最后ai美化页面这个流程能行吗?
vue在手机端上下拖拽元素的时候如何禁止父元素及body的滚动导致无法拖拽完成?
使用tailwindcss如何去掉响应式自适应?
有没有直接在浏览器中运行的离线linux系统?
nginx如何保留post或get数据进行url重定向?