百度一般都是通过站的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如何调用openai的api实现知识讲解类动画讲解视频的合成?
html如何直接调用openai的api实现海报可视化设计及文本描述生成可编辑海报?
f12前端调试如何找出按钮点击事件触发的那段代码进行调试?
abcjs如何将曲谱播放后导出mid和wav格式音频下载?
python如何将曲子文本生成音乐mp3或wav、mid文件
python中mp3、wav音乐如何转成mid格式?
js在HTML中如何将曲谱生成音乐在线播放并下载本地?
python如何实现在windows上通过键盘来模拟鼠标操作?
python如何给win10电脑增加文件或文件夹右键自定义菜单?
python如何将音乐mp3文件解析获取曲调数据?