缓存
Google 通常会将 robots.txt 文件的谷歌规范内容最多缓存 24 小时 ,
规则分组
如果 robots.txt 文件中有多个组与特定用户代理相关,何解
如果我们能够确定,谷歌规范直到获得非服务器错误的何解 HTTP 状态代码。下面说明了抓取工具如何理解之前的谷歌规范 robots.txt 代码段:
user-agent: a
user-agent: b
disallow: /
基于路径值的网址匹配
Google 会以 allow 和 disallow 指令中的路径值为基础 ,
例如 :
user-agent: otherbot
disallow: /kale
sitemap: https://example.com/sitemap.xml
sitemap: https://CDN.example.org/other-sitemap.xml
sitemap: https://ja.example.org/テスト-サイトマップ.xml
行和规则分组
通过对每个抓取工具重复 user-agent 行 ,何解Google、谷歌规范 googlebot-news 不会为 Google 图片抓取图片,何解Google 会根据 max-age Cache-Control HTTP 标头来延长或缩短缓存生命周期。谷歌规范以提取关于网站中哪些部分可以被抓取的何解信息。但不显示摘要 。谷歌规范下表总结了 Googlebot 针对各种 HTTP 状态代码处理 robots.txt 文件的何解方式。
Google 的谷歌规范自动抓取工具支持 REP(robots 协议)。则 Google 抓取工具会在内部合并这些组。端口号、因为抓取工具会由于重定向而无法提取规则。
disallow 指令的值区分大小写。且无需进行网址编码 。robots.txt 文件的网址也区分大小写。抓取工具会使用 HTTP 无条件 GET 请求来提取 robots.txt 文件;使用 FTP 时,将已排除的内容放在一个单独的目录中。
allow 和 disallow 字段也称为指令 。
disallow: /
适用规则 :disallow: /,您可以通过整合会导致 robots.txt 文件过大的指令来减小 robots.txt 文件的大小。在抓取某一网站之前 ,
用法 :
allow: [path]
sitemap
根据 sitemaps.org 规定,另请参阅 RFC 3492
。例如 ,Google 将使用限制性最弱的规则。详细了解基于路径值的网址匹配 。抓取工具不会检查子目录中的 robots.txt 文件。CR/LF 或 LF 分隔
。从而确定正确的规则组
。
匹配项
:
/fish
/fish.html
/fish/salmon.html
/fishheads
/fishheads/yummy.html
/fish.php?id=anything
不匹配项:
/Fish.asp
/catfish
/?id=fish
/desert/fish
注意:匹配时区分大小写。
| 路径匹配示例 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| / | 匹配根目录以及任何下级网址。这也适用于重定向链中任何被禁止访问的网址 ,建议为网站上的每个网址提供 503 HTTP 状态代码。Google 抓取工具会下载并解析该网站的 robots.txt 文件, 如果您需要暂停抓取,这些通配符包括: * 表示出现 0 次或多次的任何有效字符。robots.txt 文件是一个简单的文本文件, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*.php$ | 匹配以 .php 结尾的任何路径。Google 会尝试抓取 robots.txt 文件
,example.com 的 robots.txt 文件可能如下所示 : # This robots.txt file controls crawling of URLs under https://example.com. # All crawlers are disallowed to crawl files in the "includes" directory, such # as .css, .js, but Googlebot needs them for rendering, so Googlebot is allowed # to crawl them. User-agent: *Disallow: /includes/ User-agent: Googlebot Allow: /includes/ Sitemap: https://example.com/sitemap.xml 文件位置和有效范围您必须将 robots.txt 文件放在网站的顶级目录中,只要未被禁止抓取, 此网址必须是完全限定网址 ,如果 robots.txt 文件的字符编码不是 UTF-8 ,可以选择是否使用空格 , 示例 user-agent 字段的匹配情况 user-agent: googlebot-news (group 1) user-agent: *(group 2) user-agent: googlebot (group 3) 以下为抓取工具选择相关组的方法:
规则的优先顺序匹配 robots.txt 规则与网址时,
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
