Robots.txt
维基百科,自由的百科全书
robots.txt(统一小写)是一种存放于网站根目录下的ASCII编码的文本文件,它通常告诉网络搜索引擎的漫游器(又称网络蜘蛛),此网站中的哪些内容是不能被搜索引擎的漫游器获取的,哪些是可以被(漫游器)获取的。 因为一些系统中的URL是大小写敏感的,所以robots.txt的文件名应统一为小写。robots.txt应放置于网站的根目录下。如果想单独定义搜索引擎的漫游器访问子目录时的行为,那么可以将自定的设置合并到根目录下的robots.txt,或者使用robots元数据。
Robots.txt协议并不是一个规范,而只是约定俗成的,所以并不能保证网站的隐私。注意Robots.txt是用字符串比较来确定是否获取URL,所以目录末尾有和没有斜杠“/”这两种表示是不同的URL,也不能用"Disallow: *.gif"这样的通配符。
其他的影响搜索引擎的行为的方法包括使用robots元数据:<meta name="robots" content="noindex,nofollow" />这个协议也不是一个规范,而只是约定俗成的,通常搜索引擎会识别这个元数据,不索引这个页面,以及这个页面的链出页面。
Contents |
[edit] 例子
让所有机器人访问所有文件因为通配符"*"明所有机器人: <source lang="robots"> User-agent: * Disallow: </source>
拦截所有的机器人: <source lang="robots"> User-agent: * Disallow: / </source>
禁止所有机器人访问特定目录: <source lang="robots"> User-agent: * Disallow: /cgi-bin/ Disallow: /images/ Disallow: /tmp/ Disallow: /private/ </source>
仅禁止坏爬虫访问特定目录(BadBot用真实的名字代替): <source lang="robots"> User-agent: BadBot Disallow: /private/ </source>
[edit] 非标准扩展协议
[edit] Sitemaps auto-discovery
The Sitemap parameter is supported by major crawlers (including Google, Yahoo, MSN, Ask). Sitemaps specifies the location of the site's list of URLs. This parameter is independent from User-agent parameter so it can be placed anywhere in the file.
<source lang="robots"> Sitemap: http://www.example.com/sitemap.xml.gz </source>
An explanation of how to author SiteMap files can be found at sitemaps.org
[edit] Crawl-delay 指令
几大抓取工具支持Crawl-delay参数,设置为多少秒,以等待同服务器之间连续请求:[1] [2]
<source lang="robots"> User-agent: * Crawl-delay: 10 </source>
[edit] Allow 指令
一些大的Crawlers支持一项Allow指令,可以抵消先前Disallow指令。比如Googlebot 如何拦截 Googlebot。
[edit] 替代
虽然robots.txt的是老的和更为广泛接受的方法,还有其他的(可以用来连同robots.txt一起使用),允许更大的控制权,如只禁止索引图象和禁用归档页的内容。
Robots META标签则主要是针对一个个具体的页面。和其他的META标签(如使用的语言、页面的描述、关键词等)一样,Robots META标签也是放在页面的<head></head>中,专门用来告诉搜索引擎ROBOTS如何抓取该页的内容。
<source lang="html4strict"> <meta name="robots" content="noindex,nofollow" /> </source>
[edit] 外部連結
[edit] 參考文獻
- ^ How can I reduce the number of requests you make on my web site?(HTML).Yahoo! Slurp.於2007年February8日查閱.
- ^ MSNBot is crawling a site too frequently(HTML).Troubleshoot issues with MSNBot and site crawling.於2007年February8日查閱.
cs:Robots.txt da:Robots.txt de:Robots Exclusion Standard en:Robots exclusion standard es:Estándar de exclusión de robots fi:Robots.txt fr:Robots.txt he:Robots.txt it:Robots.txt ko:로봇 배제 표준 nl:Robots Exclusion Protocol pl:Robots Exclusion Protocol pt:Robots.txt ru:Robots.txt sv:Robots Exclusion Standard tr:Robots.txt