星空网 > 软件开发 > ASP.net

IIS设置文件 Robots.txt 禁止爬虫

robots.txt用于禁止网络爬虫访问网站指定目录。robots.txt的格式采用面向行的语法:空行、注释行(以#打头)、规则行。规则行的格式为:Field: value。常见的规则行:User-Agent、Disallow、Allow行。

User-Agent行

User-Agent: robot-nameUser-Agent: *

Disallow和Allow行

Disallow: /pathDisallow:      # 空字符串,起通配符效果,全禁止Allow: /pathAllow:       # 空字符串,起通配符效果,全允许

搜索引擎的User-Agent对应名称

搜索引擎User-Agent值
Googlegooglebot
百度baiduspider
雅虎slurp
MSNmsnbot
Alexais_archiver

我在Linux上抓包观察到的一些搜索引擎访问记录:

# tcpdump -n -nn -A -l -s1024 'tcp port 80'|grep User-AgentUser-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)User-Agent: Googlebot-Image/1.0User-Agent: Feedfetcher-Google; (+http://www.google.com/feedfetcher.html; 5 subscribers; feed-id=4619555564728728616)User-Agent: Mozilla/5.0(compatible; Sosospider/2.0; +http://help.soso.com/webspider.htm)User-Agent: Mozilla/5.0 (compatible; YoudaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; )User-Agent: Mozilla/5.0 (compatible; JikeSpider; +http://shoulu.jike.com/spider.html)

JikeSpider是即刻搜索(人民搜索)。

robots.txt的补充

如果你没有对网站根目录的写入权限(无法建立robots.txt文件),或你想要某个指定的网页不被搜索引擎收录,可以使用元标签阻止爬虫访问:

 name="robots" content="noindex">        name="googlerobot" content="noindex">     

robots元标记的默认值为"index,follow",它的取值可以是(来自Google站长帮助):

noindex
防止网页被编入索引。
nofollow
防止googlebot从此页面中跟踪链接。
noarchive
防止Google显示网页的快照链接。
noimageindex
不被Google图片搜索索引。

现实中的robots.txt

淘宝屏蔽百度

淘宝屏蔽了百度抓取(2008年9月),http://www.taobao.com/robots.txt的内容:

User-agent: BaiduspiderDisallow: /User-agent: baiduspiderDisallow: /

百度与360的搜索引擎之争

2012年8月,360推出搜索引擎,并与百度发生正面冲突。百度工程师跑出来说360违反robots协议,偷窃百度内容。以百度知道为例,http://zhidao.baidu.com/robots.txt的内容大致是这样:

User-agent: BaiduspiderDisallow: /w?Allow: /User-agent: GooglebotUser-agent: MSNBotUser-agent: Baiduspider-imageUser-agent: YoudaoBotUser-agent: Sogou web spiderUser-agent: Sogou inst spiderUser-agent: Sogou spider2User-agent: Sogou blogUser-agent: Sogou News SpiderUser-agent: Sogou Orion spiderUser-agent: JikeSpiderUser-agent: SosospiderAllow: /User-agent: *Disallow: /

也就是说对360爬虫而言,应该走最后一条规则,也就是禁止抓取百度知道所有内容。但从360搜索看,有百度知道的内容。




原标题:IIS设置文件 Robots.txt 禁止爬虫

关键词:IIS

IIS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流