Robots.txt - 禁止爬虫(转)
Robots.txt - 禁止爬虫
robots.txt用于禁止网络爬虫访问网站指定目录。robots.txt的格式采用面向行的语法:空行、注释行(以#打头)、规则行。规则行的格式为:Field: value。常见的规则行:User-Agent、Disallow、Allow行。
User-Agent行
User-Agent: robot-name
User-Agent: *
Disallow和Allow行
Disallow: /path
Disallow: # 空字符串,起通配符效果,全禁止 Allow: /path
Allow: # 空字符串,起通配符效果,全允许
搜索引擎的User-Agent对应名称
搜索引擎 | User-Agent值 |
---|---|
googlebot | |
百度 | baiduspider |
雅虎 | slurp |
MSN | msnbot |
Alexa | is_archiver |
我在Linux上抓包观察到的一些搜索引擎访问记录:
# tcpdump -n -nn -A -l -s1024 'tcp port 80'|grep User-Agent
User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
User-Agent: Googlebot-Image/1.0
User-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文件),或你想要某个指定的网页不被搜索引擎收录,可以使用元标签阻止爬虫访问:
<meta name="robots" content="noindex"> <!-- 阻止所有爬虫 -->
<meta name="googlerobot" content="noindex"> <!-- 阻止Google收录 -->
robots元标记的默认值为"index,follow",它的取值可以是(来自Google站长帮助):
- noindex
- 防止网页被编入索引。
- nofollow
- 防止googlebot从此页面中跟踪链接。
- noarchive
- 防止Google显示网页的快照链接。
- noimageindex
- 不被Google图片搜索索引。
现实中的robots.txt
淘宝屏蔽百度
淘宝屏蔽了百度抓取(2008年9月),http://www.taobao.com/robots.txt的内容:
User-agent: Baiduspider
Disallow: / User-agent: baiduspider
Disallow: /
百度与360的搜索引擎之争
2012年8月,360推出搜索引擎,并与百度发生正面冲突。百度工程师跑出来说360违反robots协议,偷窃百度内容。以百度知道为例,http://zhidao.baidu.com/robots.txt的内容大致是这样:
User-agent: Baiduspider
Disallow: /w?
Allow: / User-agent: Googlebot
User-agent: MSNBot
User-agent: Baiduspider-image
User-agent: YoudaoBot
User-agent: Sogou web spider
User-agent: Sogou inst spider
User-agent: Sogou spider2
User-agent: Sogou blog
User-agent: Sogou News Spider
User-agent: Sogou Orion spider
User-agent: JikeSpider
User-agent: Sosospider
Allow: / User-agent: *
Disallow: /
也就是说对360爬虫而言,应该走最后一条规则,也就是禁止抓取百度知道所有内容。但从360搜索看,有百度知道的内容。
Robots.txt - 禁止爬虫(转)的更多相关文章
- Robots.txt - 禁止爬虫
robots.txt用于禁止网络爬虫访问网站指定目录.robots.txt的格式采用面向行的语法:空行.注释行(以#打头).规则行.规则行的格式为:Field: value.常见的规则行:User-A ...
- IIS设置文件 Robots.txt 禁止爬虫
robots.txt用于禁止网络爬虫访问网站指定目录.robots.txt的格式采用面向行的语法:空行.注释行(以#打头).规则行.规则行的格式为:Field: value.常见的规则行:User-A ...
- 通过[蜘蛛协议]Robots.txt禁止搜索引擎收录的方法
什么是robots.txt文件? 搜索引擎通过一种程序robot(又称spider),自动访问互联网上的网页并获取网页信息. 您可以在您的网站中创建一个纯文本文件robots.txt,在这个文件中 ...
- robots.txt网站爬虫文件设置
目录: 什么是robots.txt robots.txt使用误区 robots.txt使用技巧 什么是robots.txt? robots.txt是搜索引擎中访问网站的时候要查看的第一个文件.Robo ...
- robots.txt禁止搜索引擎收录
禁止搜索引擎收录的方法 一.什么是robots.txt文件? 搜索引擎通过一种程序robot(又称spider),自动访问互联网上的网页并获取网页信息. 您可以在您的网站中创建一个纯文 ...
- website robots.txt 防爬虫 措施
robots.txt文件用法举例: 1. 允许所有的robot访问 User-agent: * Allow: / 或者 User-agent: * Disallow: 2. 禁止所有搜索引擎访问网站的 ...
- nginx通过robots.txt禁止所有蜘蛛访问(禁止搜索引擎收录)
在server {} 块中添加下面的配置 location =/robots.txt { default_type text/html; add_header Content-Type "t ...
- dedecms:解析Robots.txt 协议标准
Robots.txt 是存放在站点根目录下的一个纯文本文件.虽然它的设置很简单,但是作用却很强大.它可以指定搜索引擎蜘蛛只抓取指定的内容,或者是禁止搜索引擎蜘蛛抓取网站的部分或全部内容. 下面我们就来 ...
- 如何设置让网站禁止被爬虫收录?robots.txt
robot.txt只是爬虫禁抓协议,user-agent表示禁止哪个爬虫,disallow告诉爬出那个禁止抓取的目录. 如果爬虫够友好的话,会遵守网站的robot.txt内容. 一个内部业务系统,不想 ...
随机推荐
- android 尽量不要使用static静态变量
使用静态static静态变量潜在性问题: 1.占用内存,并且内存一般不会释放: 2.在系统不够内存情况下会自动回收静态内存,这样就会引起访问全局静态错误. 3.不能将activity作为static静 ...
- Redis学习笔记1-Redis的介绍和认识
说明:文章内容来自百度百科和redis官方对redis的介绍 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API ...
- linux命令:ls
命令格式: ls [OPTION]... [FILE]... 功能: 列出某个目录下的文件信息,默认列出当前目录.输出结果默认按字母顺序排列. 参数: -a, --all,-A, --almost-a ...
- vim 命令详解
vi: Visual Interface 可视化接口vim: VI iMproved VI增强版 全屏编辑器,模式化编辑器 vim模式: 编辑模式(命令模式) 输入模式 末行模式 模式转换: 编辑-- ...
- Java程序生成exe可执行文件详细教程(图文说明)
ava程序打包成exe可执行文件,分为两大步骤. 第一步:将Java程序通过Eclipse或者Myeclipse导成Jar包 第二步:通过exe4j讲Jar包程序生成exe可执行文件 第一步详解: 将 ...
- ubuntu下安装加装DNS
感觉在ubuntu下网速特别的慢,所以网上找了下解决方案,本地缓存域名解析相关信息. 首先,安装dns服务 命令: sudo apt-get install dnsmasq 编辑dnsmasq的配置文 ...
- POJ 1325 Machine Schedule——S.B.S.
Machine Schedule Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13731 Accepted: 5873 ...
- magnitude是精确距离,sqrMagnitude是节省CPU的粗略距离,精度有损失
magnitude是精确距离,sqrMagnitude是节省CPU的粗略距离,精度有损失 CubeA坐标 x:0 y:0.844 z:0 CubeC坐标 x:0 y:0 z:0 Vector3 aaa ...
- 图像旋转 OpenCV实现
经常对一幅图像进行旋转操作,OpenCV中提供了很方便易用的仿射变换函数warpAffine, 通过getRotationMatrix2D可以得到放射变换矩阵(矩阵大小2x3) #include &l ...
- 如何使用eclipse打开已有工程
在开始使用Eclipse的时候,会发现一个问题,那就是如何打开一个现有的Eclipse工程,开始在菜单中找了好久也没找到. 其实,Eclipse生成的结果不像VC,Jcreator那样可以直接打开,若 ...