笔记 by 车东

Spider: 以遵守robots.txt协议为荣 以匿名盗抓为耻

· 日志分析|Analytics

按照是否匿名和是否遵循robots.txt协议有4种蜘蛛: 1 真名真姓,遵循robots.txt 协议。代表:GoogleBot BaiduSpider MSNBot Yahoo!Slurp 等 2 真名真姓,不遵循robots.txt协议。代表:iAskSpider SohuAgent wget 3 匿名,不遵循robots.txt协议。代表:大量的匿名蜘蛛,例如 OutfoxBot; 4 伪装:不遵循robots.txt协议。代表:中搜,各种SpamBot,

如何识别这四类蜘蛛呢?通过HTTP协议和是否支持mod_gzip都很好的特征。做一个知荣知耻的spider很难吗?事实上:比较难。没有一定的技术积累,spider就和spambot一样。详细分析附后:

先看看第一类: GoogleBot: 除了遵循robots.txt外,也支持HTTP 1.1压缩,可以非常有效的节省带宽;

66.249.72.165 - - [14/Nov/2006:00:09:35 +0800] "GET [/blog/archives/000900.html](http://www.chedong.com/blog/archives/000900.html) HTTP/1.1" 200 8437 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 66.249.72.165.321101163434175289 这个页面的原始大小是34211字节。
[BaiduSpider](http://www.baidu.com/search/spider.htm):BaiduSpider不支持HTTP 1.1压缩,但使用大量使用了HEAD请求来校验文件更新,避免了很多网络传输;百度的蜘蛛支持Disallow命令,但是是抓了再删,而其他引擎是从请求队列中删除,根本不会抓取。
202.108.22.181 - - [14/Nov/2006:20:49:16 +0800] "GET /blog/atom.xml HTTP/1.1" 304 - "-" "Baiduspider+(+http://www.baidu.com/search/spider.htm)" 202.108.22.181 - - [14/Nov/2006:21:07:15 +0800] "GET /cgi-bin/mt/mt-comments.cgi HTTP/1.1" 200 2076 "-" "Baiduspider+(+http://www.baidu.com/search/spider.htm)" 202.108.22.181 - - [14/Nov/2006:21:07:17 +0800] "GET /blog/archives/000713.html HTTP/1.1" 200 31220 "-" "Baiduspider+(+http://www.baidu.com/search/spider.htm)" 202.108.22.144 - - [14/Nov/2006:22:54:22 +0800] "**HEAD** /blog/archives/000642.html HTTP/1.1" 200 0 "-" "Baiduspider+(+http://www.baidu.com/search/spider.htm)"
[Yahoo!Slurp](http://search.help.cn.yahoo.com/): 只支持HTTP 1.0,也没用HEAD来校验更新,有很多报道说雅虎的蜘蛛抓取强度过高,但是Yahoo!Slurp很遵守规矩的,而且现在支持[Crawl-delay](http://ysearchblog.cn/2006/07/yahoo_slurp.html)命令:可以控制抓取频度。

第二类的和第三类的还好办,至少方便通过web服务器通过agent判断进行控制。最烦的就是第四类:不但无法防止,还给日志统计分析带来了很多麻烦。

但如果服务上安装了mod_gzip支持,就可以区分出了:因为机器人对HTTP 1.1支持到HTTP压缩还是有一定难度的,如果来自某个IP有大量的MSIE 访问,却是只支持HTTP 1.0请求或者支持HTTP 1.1但又不支持压缩那个就有可能是伪装spam了。

中搜多年以来一直伪装成Mozilla/4.0 (compatible;MSIE 5.5;Windows NT 5.0),从中搜上的CrawledBy结果就可以看出来:

ipfw - phpMan Apache/1.3.37 (Unix) mod_perl/1.29 PHP/4.4.2 Under GNU General Public License 2006-10-25 11:23 @202.108.1.6 CrawledBy **Mozilla/4.0 (compatible;MSIE 5.5;Windows NT 5.0)** www.chedong.com/phpMan.php/man/ipfw 上的更多结果 2006-10-25

做一个知荣知耻的spider很难吗?

💬 历史评论

以下 25 条评论从旧版 Movable Type 博客迁移而来。 原始评论时间:2002–2016 年。

number5 · 2006-11-24 13:45

BaiduSpider 好像不大稳定, 有时候会在一个小时之内疯狂的爬你的网站数十次, 频率比GoogleBot和MSNbot都要高出很多

BTW: Atom/RSS里面可不可以放全部内容啊? 你加了之后, feed里面也只能看到一半了


shunz · 2006-11-24 13:56

真不明白他们为什么要伪装成普通浏览器?


cloudchen · 2006-11-24 14:14

伪装成常用的Agent能爬到更多的东西,有些资源判断Agent的


anti · 2006-11-24 15:39

BaiduSpider根本就不遵守robots.txt啊….


York · 2006-11-24 21:39

baiduspider好像支持robots.txt,但是不支持meta中的robots定义,而且我觉得baiduspider可能有时候会匿名来爬网页。 总之,极其唾弃这些不遵守协议的垃圾spider!


Cloudream · 2006-11-24 21:54

百度不是抓了再搜,是在审核互联网……


Fenng · 2006-11-24 22:59

国内土生土长的搜索引擎,似乎遵循标准的很少

甚至有的搜索引擎站点都不介绍自己的蜘蛛相关信息


Zhou Renjian · 2006-11-25 00:09

http://bl.ognize.com/whizznotes/xhtml/3966.html

We should ban Baiduspider!

从log来看,百度蜘蛛(Baiduspider)不理会robots.txt的存在!或者更新robots.txt的频率实在太低!以至于你新添了应用,同时更改了robots.txt,但百度蜘蛛依旧会在一个月内或更长时间内爬行你禁止了的页面!

基于此行为,建议禁止Baiduspider的访问!

另外国内的sogou也是不遵守robots.txt规范的,属于第二类。


netcasper · 2006-11-25 15:16

不知道你为什么认为wget不遵循robots.txt协议?

即使是在你链接的man page上也说“This is sometimes referred to as ‘‘recursive downloading.’’ While doing that, Wget respects the Robot Exclusion Standard (/robots.txt).”

只不过wget有选项可以做到不遵循robots.txt协议而已,这与完全不遵循还是不一样的吧。

http://www.gnu.org/software/wget/manual/html_node/Robot-Exclusion.html

我在自己的站点上做了实验,用的是Fedora Core 6上的wget 1.10.2。


flymorn · 2006-11-26 10:00

国内许多的spide没有那么强的意识,专占便宜,图点他们认为有价值的资源,不让你抓,就是抓,强奸民意!


zhuwei · 2006-11-26 23:59

支持robots.txt的在线sitemap.xml生成工具,错误链接检查工具,没有链接数量限制.欢迎大家测试. 地址: http://lab.huluwa.cn/query/sitemap.htm


concorde · 2006-11-29 12:58

我试过wget遵守reobots.txt


Jester · 2006-12-22 16:14

我目前遇到的最无耻的spider是新浪的Iask!

几个月前我突然发现自己的网站每天的流量特别大,一两天就有好几个G。因为我们是一个专业学术网站,平时的访问量应该没有那么多的。所以我就开始仔细的分析日志。结果就发现是Sina Iask Spider! 因为我的网站有很多用CGI做的动态链接,理论上可以产生上千万个不同的访问地址,所以Iaskspider就在拼命的抓取我的网页。而且一般都是一秒钟内同时抓取四五个页面!这简直就和攻击没什么区别嘛! 这令我非常的生气,因为我在robots里是明确写了禁止访问CGI的目录的。但是事实上,通过日志可以看出Sina Iask Spider从来就没有抓取过robots.txt文件,所以它根本就不会遵守。无耻的Iask! 我决定屏蔽Iask,通过日志我得到了两个IP: 219.142.118.41 219.142.118.54 于是就用iptables直接reject。这样总算在后来的几个月内没有再看到Iask。

然而,最近几天突然又出现了大量的spider的访问。日志显示是一个名为“IaskLinkChecker1.0”的家伙! 和前面的Iaskspider一样,从不抓取robots,疯狂的在十个小时内从我的网站抓取了近十万个页面,2个多G流量! 我真不明白,为什么Iask竟然如此无耻,根本就是个流氓搜索引擎!! 于是,我只能继续reject这些IP(这次居然有好几个不同的IP——看来Iask在扩增spider服务器吗?),不管如何我是见一个屏蔽一个的,建议大家也要小心了: 202.106.182.157 202.106.184.179 60.28.164.121 60.28.164.123 61.135.152.120 目前发现的就是这几个,没准以后还会有。真不知道除了封IP还有什么其它办法可以比较彻底的防止这个流氓……

另外,补充一下,Iaskspider还有两个IP,看看这个日志: 60.28.164.41 - - [10/Dec/2006:04:07:42 +0800] “GET / HTTP/1.0” 200 5299 “-” “Mozilla/5.0 (compatible; iaskspider/1.0; MSIE 6.0)” 60.28.164.35 - - [10/Dec/2006:12:06:30 +0800] “GET / HTTP/1.0” 200 5299 “-” “Mozilla/5.0 (compatible; iaskspider/1.0; MSIE 6.0)”

但不知道为什么,这两个IP就是只抓取了index页面,其它都没有。也许是提供给了其它的spider服务器用? 不管如何,我是最痛恨这种流氓行为了,所以现在我只要看到iask就封掉! iask根本就是个流氓垃圾网站,建议大家一起来抵制它!!


布老虎 · 2006-12-27 22:57

感觉楼主就好像是黄金圣斗士,再在暝斗士在斗法呢。。。嘿嘿。。历害。。。崇拜中。。。。


Jester · 2007-01-04 11:34

今年一来又看到了一个新的IP: 60.28.164.88 - - [01/Jan/2007:15:27:38 +0800] “GET / HTTP/1.0” 200 5275 “-” “Mozilla/5.0 (compatible; iaskspider/1.0; MSIE 6.0)”

难道60.28.164.*这整个C类网段都是iaskspider的?如果还出现这个网段的iaskspider,我就准备把它们整个封掉了——宁可错杀,也不能有漏网! :-O


图图 · 2007-04-24 18:46

我的网站好惨,也不知道是哪里的IP: 824 天津市 网通ADSL 60.28.164.40 other other 2007-4-24 18:41:36 823 天津市 网通ADSL 60.28.164.89 other other 2007-4-24 18:40:47 822 天津市 网通ADSL 60.28.164.43 other other 2007-4-24 18:40:21 821 天津市 网通ADSL 60.28.164.87 other other 2007-4-24 18:39:57 819 天津市 网通ADSL 60.28.164.69 other other 2007-4-24 18:20:52 818 天津市 网通ADSL 60.28.164.85 other other 2007-4-24 18:20:18 817 天津市 网通ADSL 60.28.164.40 other other 2007-4-24 18:20:06 816 天津市 网通ADSL 60.28.164.67 other other 2007-4-24 18:19:41 815 天津市 网通ADSL 60.28.164.27 other other 2007-4-24 18:19:13 814 天津市 网通ADSL 60.28.164.76 other other 2007-4-24 18:19:04 813 天津市 网通ADSL 60.28.164.68 other other 2007-4-24 18:18:50 812 天津市 网通ADSL 60.28.164.49 other other 2007-4-24 18:18:31 811 天津市 网通ADSL 60.28.164.59 other other 2007-4-24 18:04:10 810 天津市 网通ADSL 60.28.164.83 other other 2007-4-24 18:03:52
809 天津市 网通ADSL 60.28.164.23 other other 2007-4-24 18:03:35
808 天津市 网通ADSL 60.28.164.62 other other 2007-4-24 18:03:19
807 天津市 网通ADSL 60.28.164.78 other other 2007-4-24 18:02:59
806 天津市 网通ADSL 60.28.164.47 other other 2007-4-24 18:02:21
805 天津市 网通ADSL 60.28.164.74 other other 2007-4-24 18:02:00
804 天津市 网通ADSL 60.28.164.32 other other 2007-4-24 17:51:38
803 天津市 网通ADSL 60.28.164.60 other other 2007-4-24 17:51:26
802 天津市 网通ADSL 60.28.164.85 other other 2007-4-24 17:51:23
801 天津市 网通ADSL 60.28.164.62 other other 2007-4-24 17:50:43
800 天津市 网通ADSL 60.28.164.82 other other 2007-4-24 17:50:25
799 天津市 网通ADSL 60.28.164.35 other other 2007-4-24 17:50:21
798 天津市 网通ADSL 60.28.164.27 other other 2007-4-24 17:50:13
797 天津市 网通ADSL 60.28.164.30 other other 2007-4-24 17:49:39
796 天津市 网通ADSL 60.28.164.54 other other 2007-4-24 17:49:20
795 天津市 网通ADSL 60.28.164.87 other other 2007-4-24 17:49:06
794 天津市 网通ADSL 60.28.164.61 other other 2007-4-24 17:49:00
793 天津市 网通ADSL 60.28.164.59 other other 2007-4-24 17:38:39
792 天津市 网通ADSL 60.28.164.25 other other 2007-4-24 17:38:12
791 天津市 网通ADSL 60.28.164.44 other other 2007-4-24 17:38:08
790 天津市 网通ADSL 60.28.164.38 other other 2007-4-24 17:37:59
789 天津市 网通ADSL 60.28.164.31 other other 2007-4-24 17:37:27
788 天津市 网通ADSL 60.28.164.83 other other 2007-4-24 17:37:14
787 天津市 网通ADSL 60.28.164.54 other other 2007-4-24 17:37:08
786 天津市 网通ADSL 60.28.164.64 other other 2007-4-24 17:36:55
785 天津市 网通ADSL 60.28.164.52 other other 2007-4-24 17:36:47
784 天津市 网通ADSL 60.28.164.80 other other 2007-4-24 17:36:38
782 天津市 网通ADSL 60.28.164.79 other other 2007-4-24 17:36:03
781 天津市 网通ADSL 60.28.164.35 other other 2007-4-24 17:35:59
780 天津市 网通ADSL 60.28.164.55 other other 2007-4-24 17:35:47
779 天津市 网通ADSL 60.28.164.28 other other 2007-4-24 17:35:35
777 天津市 网通ADSL 60.28.164.56 other other 2007-4-24 17:23:32
776 天津市 网通ADSL 60.28.164.22 other other 2007-4-24 17:23:29
775 天津市 网通ADSL 60.28.164.90 other other 2007-4-24 17:23:25
774 天津市 网通ADSL 60.28.164.42 other other 2007-4-24 17:23:21
773 天津市 网通ADSL 60.28.164.25 other other 2007-4-24 17:23:07
772 天津市 网通ADSL 60.28.164.40 other other 2007-4-24 17:22:58
771 天津市 网通ADSL 60.28.164.54 other other 2007-4-24 17:22:49
770 天津市 网通ADSL 60.28.164.59 other other 2007-4-24 17:22:40
769 天津市 网通ADSL 60.28.164.66 other other 2007-4-24 17:22:24 768 天津市 网通ADSL 60.28.164.87 other other 2007-4-24 17:22:17 767 天津市 网通ADSL 60.28.164.37 other other 2007-4-24 17:22:02 766 天津市 网通ADSL 60.28.164.53 other other 2007-4-24 17:21:53 765 天津市 网通ADSL 60.28.164.40 other other 2007-4-24 17:21:41 764 天津市 网通ADSL 60.28.164.83 other other 2007-4-24 17:21:33 763 天津市 网通ADSL 60.28.164.30 other other 2007-4-24 17:21:27 762 天津市 网通ADSL 60.28.164.54 other other 2007-4-24 17:21:23 761 天津市 网通ADSL 60.28.164.37 other other 2007-4-24 17:21:03 760 天津市 网通ADSL 60.28.164.36 other other 2007-4-24 17:20:50 758 天津市 网通ADSL 60.28.164.60 other other 2007-4-24 17:06:15
757 天津市 网通ADSL 60.28.164.74 other other 2007-4-24 17:06:01
756 天津市 网通ADSL 60.28.164.81 other other 2007-4-24 17:05:30
755 天津市 网通ADSL 60.28.164.64 other other 2007-4-24 17:05:08
754 天津市 网通ADSL 60.28.164.73 other other 2007-4-24 17:04:55
753 天津市 网通ADSL 60.28.164.31 other other 2007-4-24 17:04:29
752 天津市 网通ADSL 60.28.164.61 other other 2007-4-24 17:04:10
751 天津市 网通ADSL 60.28.164.61 other other 2007-4-24 17:03:59
750 天津市 网通ADSL 60.28.164.61 other other 2007-4-24 17:03:46
749 天津市 网通ADSL 60.28.164.76 other other 2007-4-24 17:03:25
748 天津市 网通ADSL 60.28.164.37 other other 2007-4-24 16:53:16
747 天津市 网通ADSL 60.28.164.77 other other 2007-4-24 16:52:40
746 天津市 网通ADSL 60.28.164.48 other other 2007-4-24 16:52:15
745 天津市 网通ADSL 60.28.164.53 other other 2007-4-24 16:51:23
744 天津市 网通ADSL 60.28.164.67 other other 2007-4-24 16:51:10
743 天津市 网通ADSL 60.28.164.74 other other 2007-4-24 16:50:51
742 天津市 网通ADSL 60.28.164.23 other other 2007-4-24 16:50:39
741 天津市 网通ADSL 60.28.164.43 other other 2007-4-24 16:50:29
739 天津市 网通ADSL 60.28.164.73 other other 2007-4-24 16:39:27
738 天津市 网通ADSL 60.28.164.72 other other 2007-4-24 16:39:13
737 天津市 网通ADSL 60.28.164.72 other other 2007-4-24 16:38:41
736 天津市 网通ADSL 60.28.164.57 other other 2007-4-24 16:38:34
735 天津市 网通ADSL 60.28.164.75 other other 2007-4-24 16:38:00
734 天津市 网通ADSL 60.28.164.81 other other 2007-4-24 16:37:47
733 天津市 网通ADSL 60.28.164.81 other other 2007-4-24 16:37:37
732 天津市 网通ADSL 60.28.164.22 other other 2007-4-24 16:37:13
731 天津市 网通ADSL 60.28.164.33 other other 2007-4-24


Jester · 2007-05-08 16:53

对于不良网段就不要手软了,建议试试这样:^_^ iptables -A INPUT -s 60.28.164.0/24 -j REJECT


刘明 · 2007-08-01 16:05

试试过滤行不行?我做Java开发的,为了防止恶意刷新直接使用Filter,一定时限内的连续访问,直接黑名单。再访问就拒绝。不过麻烦的是如果对方用的代理就不好办了,那样等于直接把代理给封了。不过还好我们没这个问题(手机网站,没人用代理上吧?)。


Jester · 2007-08-22 12:02

前些日子突然发现访问统计流量变大了,觉得有些不太正常,所以check了一下日志,找到了一个IP:38.99.44.104,大量的访问我的cgi程序(但是这在我的robots设置里面是禁止的。 它自称是(Twiceler-0.9 http://www.cuill.com/twiceler/robot.html) 我去这个地址看了一下,好像是一个国外新做的spider,并且网页上说可以用twiceler作为user-agent来对robot进行限制。 本想直接屏蔽IP的,但是又担心以后它换了IP比较麻烦,于是抱着试试看得心理,重新设置了robots.txt,加上了: User-Agent: twiceler Disallow: * 因为,可能是原来的robots设置比较复杂,估计是这个新的spider没有看懂吧(呵呵,明显需要改进阿)。

这样过了一周以后,我又突然想起了这件事情(我是个业余管理员,不是天天都做这个的),于是又看了一下日志,结果发现,这个spider果然在两天后就开始只抓取robots.txt了,就这样的一条记录: 38.99.44.104 - - [21/Aug/2007:23:20:32 +0800] “GET /robots.txt HTTP/1.0” 200 517 “-” “Mozilla/5.0 (Twiceler-0.9 http://www.cuill.com/twiceler/robot.html)"

我很高兴看到了一个比较文明的spider,由此又想起了去年和iaskspider的苦斗。虽然几个月前曾经有个自称是iask的技术人员给我发了email,说是看到了这个帖子,他们正在努力的改进等等。 但是,至今我还是心有余悸,这些IP的屏蔽我一直都不敢去掉……

做一个文明的spider真的就那么难吗?好像不是吧。这应该不是技术上问题了,而是一个基本素质的问题。能够忽略robots的设置去别人不想给你的东西,是不是就让一些做spider的人觉得很得意了?这是标准的小人心态。唉,除了鄙视,我无话可说……

同样都是做spider,差距咋就这么大呐……


宁波人才网 · 2008-06-08 15:23

遵守reobots.txt 可是百度好像对这个很不敏感


笑容 · 2008-07-01 16:37

yahoo 不遵守 robots.txt信息

下面是我的 robots.txt 链接

http://www.dyos.cn/robots.txt

yahoo 国内和国外的robot仍然乐此不疲的抓着。而搜索访问中,通过yahoo过来的几乎是0,问题是 在yahoo搜索里 site一下 光抓取了,没几条结果被显示出来,不知道这只知道吃的蜘蛛 干嘛用的哈

www.dyos.cn


iamfisher · 2008-12-06 00:14

cuill就是那传说中的Google杀手。文明的杀手。

  • Soso-spider 分析robots的bot和抓内容的bot,不同步。BaiduSpider也是这样,不同步。

土鳖的spider,大多数是效率优先、规则第二。


yeml · 2009-03-26 11:38

由: Jester 发表于 2007年05月08日 下午04时53分

试试过滤行不行?我做Java开发的,为了防止恶意刷新直接使用Filter,一定时限内的连续访问,直接黑名单。再访问就拒绝。不过麻烦的是如果对方用的代理就不好办了,那样等于直接把代理给封了。不过还好我们没这个问题(手机网站,没人用代理上吧?)。


哈哈,手机网站没人用代理上???错啦,手机上网只要使用cmwap,都要经过移动的网关,就是代理服务器,所以你千万不要把ip封了,不然可能一个省的用户都没办法上你的网站,损失可大啦


windy · 2011-05-14 20:33

实际上网站的内容对于这些蜘蛛基本上是不设防的,没办法,搜索引擎太霸道了,现在基本上站长只有察言观色的份儿,还能怎么办呢? 我的网站www.diyifangshui.com也是,不希望被浏览的内容他们照看不误!


西楚博客 · 2011-08-14 09:15

我的博客百度蜘蛛就是不遵守robots.txt协议!!http://www.xichucn.com