百度一般都是通过站的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”
网友回复
DLNA与UPnP的区别和不同?
苏超自建抢票app,通过先预约再抽签化解高并发抢票?
python如何让给电脑在局域网中伪装成电视接收手机的投屏图片视频播放?
如何结合python+js如何自己的视频编码与加密播放直播?
python如何在电脑上通过局域网将本地视频或m3u8视频投屏电视播放?
腾讯视频爱奇艺优酷vip电影电视剧视频如何通过python绕过vip收费直接观看?
有没有可免费观看全球电视台直播m3u8地址url的合集?
有没有实现观影自由的免vip影视苹果 CMS V10 API的可用url?
python如何实时检测电脑usb插入检测报警?
如何判断真人操作的鼠标移动直线轨迹与机器操作的轨迹?