天天看點

豆瓣robots.txt分析

豆瓣的robots内容如下:

========================================================

User-agent: *

Disallow: /subject_search

Disallow: /amazon_search

Sitemap: http://www.douban.com/sitemap_index.xml

Sitemap: http://www.douban.com/sitemap_updated_index.xml

User-agent: Slurp

User-agent: Sosospider

Crawl-delay: 5

Visit-time: 0100-1300

Request-rate: 40/1m 0100 - 0759

Request-rate: 12/1m 0800 - 1300

========================================================

下面來解釋下含義:

robots.txt檔案中各項目的格式為: :

常用的field有Allow, Disallow, Request-rate, Visit-time, User-agent, Robot-version等.robots.txt檔案中的注釋以'#'開始.可以為獨立的一行,也可以一行的後面部分.下面對每一個field,也叫directive進行一一介紹:

1. User-agent: The value of this field is the name of the robot the record is describing access policy for.

例子:User-agent: *

在這裡*代表,any robot that has not matched any of the other records

2. Disallow: 指定不能通路我URL

例子: Disallow: /foo.html #foo.html不能通路

Disallow: #該目錄下所有URL都可通路

Disallow: / #該目錄下所有URL都不可以通路

3. Allow: 用來指定能通路的URL, 這個在當指定所有URL為不可通路,然後可以用這個排除特殊的一些. 這時候比較友善.

例子: Allow: / #允許通路所有URL

>>>> 一般的網站基本用到這些,下面用的就不多了,是以好多人看不懂,一般大型網站用的比較多,大家可以學習下。

4. Robot-version: 用來指定robot協定的版本号

例子: Robot-version: Version 2.0

5.Crawl-delay:雅虎YST一個特定的擴充名,可以通過它對我們的抓取程式設定一個較低的抓取請求頻率。您可以加入Crawl-delay:xx訓示,其中,“XX”是指在crawler程式兩次進入站點時,以秒為機關的最低延時。

6. Visit-time:隻有在visit-time指定的時間段裡,robot才可以通路指定的URL,否則不可通路.

例子: Visit-time: 0100-1300 #允許在淩晨1:00到下午13:00通路

7. Request-rate: 用來限制URL的讀取頻率

例子: Request-rate: 40/1m 0100 - 0759 在1:00到07:59之間,以每分鐘40次的頻率進行通路

Request-rate: 12/1m 0800 - 1300 在8:00到13:00之間,以每分鐘12次的頻率進行通路

另外還有一點:robots.txt檔案裡還可以直接包括在sitemap檔案的連結。就像這樣:

Sitemap: http://czseo.9d88.com/sitemap.xml (此處請填寫XML地圖的絕對路徑,即完整URL,如果按習慣填寫Sitemap: /sitemap.xml,送出給Google網站管理者工具後會提示:檢測到無效的 Sitemap 網址;文法錯誤。

XML地圖必須在網站根目錄下才有效。)

轉自http://czseo.9d88.com/1025.html

繼續閱讀