PJzhang:robots协议的实际场景

猫宁!!!

参考链接:

https://bbs.360.cn/thread-15062960-1-1.html

https://ziyuan.baidu.com/college/courseinfo?id=150

看到robots这个关键词,先了解一下它的定义,如下是百度百科介绍:

robots是网站跟爬虫间的协议,用简单直接的txt格式文本方式告诉对应的爬虫被允许的权限,也就是说robots.txt是搜索引擎中访问网站的时候要查看的第一个文件。当一个搜索蜘蛛访问一个站点时,它会首先检查该站点根目录下是否存在robots.txt,如果存在,搜索机器人就会按照该文件中的内容来确定访问的范围;如果该文件不存在,所有的搜索蜘蛛将能够访问网站上所有没有被口令保护的页面。

展示一个robots.txt使用的例子:

https://cn.bing.com/robots.txt,这是必应搜索的robots.txt文件,节取其中一部分。

User-agent: msnbot-media

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,也许可以看到互联网江湖的一些刀光剑影的余晖。

猜你喜欢

转载自www.cnblogs.com/landesk/p/10984431.html