猫宁!!!html
参考连接:ide
https://bbs.360.cn/thread-15062960-1-1.html测试
https://ziyuan.baidu.com/college/courseinfo?id=150网站
看到robots这个关键词,先了解一下它的定义,以下是百度百科介绍:搜索引擎
robots是网站跟爬虫间的协议,用简单直接的txt格式文本方式告诉对应的爬虫被容许的权限,也就是说robots.txt是搜索引擎中访问网站的时候要查看的第一个文件。当一个搜索蜘蛛访问一个站点时,它会首先检查该站点根目录下是否存在robots.txt,若是存在,搜索机器人就会按照该文件中的内容来肯定访问的范围;若是该文件不存在,全部的搜索蜘蛛将可以访问网站上全部没有被口令保护的页面。url
展现一个robots.txt使用的例子:xml
https://cn.bing.com/robots.txt,这是必应搜索的robots.txt文件,节取其中一部分。htm
User-agent: msnbot-mediablog
Disallow: /索引
Allow: /th?
User-agent: Twitterbot
Disallow:
User-agent: *
Disallow: /account/
Disallow: /amp/
Disallow: /bfp/search
Disallow: /bing-site-safety
Disallow: /blogs/search/
Disallow: /entities/search
Disallow: /fd/
Disallow: /history
Disallow: /hotels/search
Disallow: /images?
Disallow: /images/search?
Disallow: /images/search/?
Sitemap: http://cn.bing.com/dict/sitemap-index.xml
只有当网站运营者不想让一些网页被搜索引擎收录,才会采用robots.txt,不然表示默认全站均可以被搜索引擎爬取收录了。
robots.txt文件放于根目录,内容可包含多条记录,中间用空行分割,若是robots.txt中什么都没有,表示全站能够爬取。
User-agent: *,表示针对全部爬虫。
User-agent: Twitterbot,表示针对Twitterbot这一种爬虫。
Disallow: /bfp/search,表示爬虫不能访问以/bfp/search开头的全部url页面,例如/bfp/search/abc.html,/bfp/searchabc.html等等,固然直接不容许对方访问某一个特定的url也是能够的。
Allow: /bfp/search/vip,表示爬虫能够访问/bfp/search/vip开头的全部url页面。
Sitemap: http://cn.bing.com/dict/sitemap-index.xml,告知爬虫这个文件是站点地图
Allow和Disallow结合使用,灵活掌握爬虫所访问的页面内容,不至于致使一刀切的局面。
这里严格区分字母的大小写。
*,星号表示0个及以上字符。
$,美圆符号表示结束符。
这两个都是通配符
禁止全部搜索引擎访问网站的任何目录。
User-agent: *
Disallow: /
容许全部的搜索引擎访问网站的任何目录
User-agent: *
Allow: /
禁止百度访问网站的任何目录
User-agent: Baiduspider
Disallow: /
仅容许百度访问网站的任何目录
User-agent: Baiduspider
Allow: /
禁止访问/abc/开头下的目录,可是其中的html后缀文件除外
User-agent: *
Disallow: /abc/
Allow:/abc/*.html$
禁止访问网站中的全部动态页面,注意字符全都是英文字符
User-agent: *
Disallow: /*?*
以上的都是一些基本的解释说明,能够经过查看知名站点的robots.txt文件,了解对方不想要让搜索引擎抓取的路径,对于渗透测试有时会有新的发现或启发。
http://www.dianping.com/robots.txt,能看出来大众点评不但愿全部的爬虫爬取其中的7个目录,例如优惠券、图片、帐户等等,但绝对禁止爱帮网(聚合本地生活信息)和口碑网(阿里巴巴旗下生活信息平台)这两家的爬虫爬取任何大众点评域名www.dianping.com上的东西。
所有内容
User-agent: *
Disallow: /coupon/
Disallow: /events/
Disallow: /thirdconnect/
Disallow: /member/
Disallow: /album/
Disallow: /dplab/
User-agent: www.aibang.com Disallow: /
User-agent: aibang.com Disallow: /
User-agent: aibang Disallow: /
User-agent: aibangspider Disallow: /
User-agent: aibang-spider Disallow: /
User-agent: aibangbot Disallow: /
User-agent: aibang-bot Disallow: /
User-agent: koubeispider Disallow: /
User-agent: koubei.com Disallow: /
认真解读一家站点的robots.txt,也许能够看到互联网江湖的一些刀光剑影的余晖。