今天同事发现我们的一个内部站点被baidu索引了,这个站点一直是有IP访问限制的,也不知道百度的爬虫是如何进来的。用同样的关键词在Google中搜索没有结果,顿时对baidu的技术十分”敬仰“。查了baidu的声明,如果希望站点不被他们索引,要做两件事:一是给他们发邮件,请求取消索引;二是在网站中使用Robot Exclusion拒绝爬虫。
做为网站管理员有两种方法对爬虫说”不“:
1. 在网站根目录添加robots.txt,告诉爬虫哪些目录是不让它去的。每个站点只能有唯一一个robots.txt在其根目录,并且只能有小写字母给robots.txt命名。
假如网站地址是http://www.somesite.com/,那么robots.txt就应该放在http://www.somesite.com/robots.txt
A.拒绝爬虫索引整个站点
User-agent: *
Disallow: /
B.允许爬虫访问整个站点
User-agent: *
Disallow:
C.拒绝爬虫索引站点部分目录,比如 temp,img目录
User-agent: *
Disallow: /temp/
Disallow: /img/
D.允许或者拒绝某些搜索引擎的爬虫,只要在User-agent中指定这些爬虫名字即可,下面是baidu和Google的爬虫名
baidu是:Baiduspider , Google是:Googlebot
2.在网页中直接加MATA标签。这一做法目前只被某些robot支持。例如:
[html]meta name=”robots” content=”index,follow”
meta name=”robots” content=”noindex,follow”
meta name=”robots” content=”index,nofollow”
meta name=”robots” content=”noindex,nofollow”[/html]
index表示允许索引类的robots,follow表示robots可以追踪网页上的链接
Recent Comments