AI 爬蟲:實測 GPTBot 與 ClaudeBot 造訪,以及用 robots.txt 與 nginx 封鎖的設定

AI 爬蟲是 AI 公司為了模型訓練、AI 搜尋與回答使用者問題而收集網頁的機器人。為了確認這些機器人造訪 Nginx + Apache 構成伺服器的頻率,把來源伺服器 14 天存取記錄中的 UA 與各公司公開的 IP 範圍比對,結果官方範圍的請求共 18,605 次,並依官方文件整理了在 robots.txt 與 nginx 封鎖或允許它們的設定。
期間為 2026 年 10 月 4 日到 17 日;由前端快取回應而沒有到達來源伺服器的請求,以及沒有記錄真實 IP 的請求,都不包含在數字中。
1️⃣ 辨識 AI 爬蟲:存取記錄的 UA 與公開 IP 範圍
記錄中標為 GPTBot 的請求並不全都來自 OpenAI。UA 是請求方自己寫好送來的文字,所以任何人都能掛上 GPTBot 或 ClaudeBot 的名稱發出請求。
因此先依 UA 計算各機器人名稱的請求數,再與各公司公開的 IP 範圍比對。以下是一天記錄中 AI 機器人名稱的計數結果。
grep -oiE '(GPTBot|OAI-SearchBot|ChatGPT-User|ClaudeBot|Claude-User|Claude-SearchBot|PerplexityBot|Perplexity-User|Bytespider|CCBot|Amazonbot|meta-externalagent)/' access.log-20261018 | sort | uniq -c | sort -rn 2968 GPTBot/
2084 ClaudeBot/
622 meta-externalagent/
535 Amazonbot/
167 PerplexityBot/
99 OAI-SearchBot/
30 ChatGPT-User/
21 Claude-User/
17 Claude-SearchBot/
12 Meta-ExternalAgent/
10 Perplexity-User/
7 CCBot/在名稱後加上 [/] 來計數,就會排除像 Claude-SearchBot UA 中聯絡地址 claudebot@ 這類不是名稱的文字,而大小寫記錄不同的名稱會分開計算。接著從第一欄確認 GPTBot 的請求來自哪些 IP。
grep 'GPTBot/' access.log-20261018 | awk '{print $1}' | sort | uniq -c | sort -rn | head -5 2524 74.7.x.x
428 185.152.x.x
12 34.53.x.x
1 74.7.x.x
1 172.182.x.x經過 CDN 或代理伺服器的請求,第一欄記錄的是中介伺服器的位址,所以這類行要用記錄行尾 X-Forwarded-For 欄的位址比對。OpenAI 以 JSON 檔公開 GPTBot 的 IP 範圍。
curl -s https://openai.com/gptbot.json -o gptbot.jsonIP 是否在下載的範圍檔中,可以用 Python 內建模組 ipaddress 確認。
# inrange.py — 確認 IP 是否在 JSON 範圍檔中
import json, sys, ipaddress
nets = [ipaddress.ip_network(p.get('ipv4Prefix') or p.get('ipv6Prefix')) for p in json.load(open(sys.argv[1]))['prefixes']]
for a in sys.argv[2:]:
ip = ipaddress.ip_address(a)
print(a, 'IN' if any(ip in n for n in nets) else 'OUT')在範圍檔名稱後面接著放入要確認的 IP。
python3 inrange.py gptbot.json 74.7.x.x 34.53.x.x74.7.x.x IN
34.53.x.x OUT送出 2,524 次請求的 IP 在公開範圍內,送出 12 次的 IP 則在範圍外。Anthropic、Perplexity、Apple、Common Crawl、Google 與 Bing 也公開相同格式的範圍檔,Amazonbot 則以反向 DNS 是否以 crawl.amazonbot.amazon 結尾來確認。這就像機場的出入境審查核對的是護照,而不是登機證上的名字。
這樣比對 14 天的結果,70 個 IP 輪流使用 GPTBot、ClaudeBot、Googlebot 等 23 個機器人名稱,送出 48,041 次請求,其中 57% 是 .php 或 .env 這類尋找漏洞的網址。掛著 Google-Extended 名稱的 809 次請求也全部來自這個群組;依 Google 文件,Google-Extended 是沒有 HTTP 請求用 UA 的 robots.txt 專用 token。
2️⃣ 各 UA 的造訪次數:14 天實測與每週趨勢
下表是 10 月 4 日到 17 日共 14 天的請求數。有公開範圍的機器人只計算範圍內的請求,沒有比對範圍的機器人則排除冒充群組後以 UA 計算。
| 機器人 | 公司 | 14 天請求 | 確認方式 | 冒充群組 |
|---|---|---|---|---|
| ClaudeBot | Anthropic | 10,305 | 公開 IP 範圍 | 2,387 |
| PerplexityBot | Perplexity | 3,406 | 公開 IP 範圍 | 2,262 |
| GPTBot | OpenAI | 2,546 | 公開 IP 範圍 | 2,328 |
| OAI-SearchBot | OpenAI | 1,399 | 公開 IP 範圍 | 2,347 |
| ChatGPT-User | OpenAI | 334 | 公開 IP 範圍 | 2,409 |
| Applebot | Apple | 330 | 公開 IP 範圍 | 2,372 |
| CCBot | Common Crawl | 275 | 公開 IP 範圍 | 2,275 |
| Claude-User | Anthropic | 10 | 公開 IP 範圍 | 2,192 |
| Claude-SearchBot | Anthropic | 0 | 公開 IP 範圍 | 2,297 |
| Perplexity-User | Perplexity | 0 | 公開 IP 範圍 | 2,235 |
| Meta-ExternalAgent | Meta | 14,384 | UA | 2,339 |
| Bytespider | ByteDance | 6,569 | UA | 2,336 |
| Amazonbot | Amazon | 3,493 | UA · 反向 DNS | 2,379 |
| Googlebot(比較) | 10,545 | 公開 IP 範圍 | 3,951 | |
| bingbot(比較) | Microsoft | 13,477 | 公開 IP 範圍 | 1,551 |
在公開範圍確認的 AI 爬蟲中,ClaudeBot 以 10,305 次最多,其次是 PerplexityBot 3,406 次與 GPTBot 2,546 次。Claude-SearchBot 與 Perplexity-User 來自公開範圍的請求為 0 次,同名的請求全部來自冒充群組。
濾掉冒充後仍留下的問題,是沒有比對範圍的機器人。Meta-ExternalAgent 以 UA 計算的 14,384 次最多,但確認過的 Meta 爬蟲文件中沒有 IP 範圍清單,因此只以 UA 計算。
以週來看,GPTBot 在 12 次到 3,383 次之間起伏,ClaudeBot 則五週都維持在 6,930~10,217 次。
3️⃣ 拿走哪些網址:網址類型與回應碼
AI 爬蟲拿走的不只是文章本文。14 天中 Meta-ExternalAgent 的請求有 21% 是圖片,公開範圍的 GPTBot 請求 RSS 摘要 476 次,ClaudeBot 請求網站地圖 314 次。
其他語言版本的網址也會一起收集,以公開範圍計算,ClaudeBot 的 1,111 次請求與 GPTBot 的 436 次請求是其他語言版本的文章。回應碼可以直接從一天的記錄計算。
grep 'ClaudeBot/' access.log-20261018 | awk '{print $9}' | sort | uniq -c | sort -rn | head -4 1357 200
665 301
31 304
21 404即使只看一天,301 也將近三分之一;14 天中,公開範圍的 ClaudeBot 請求 10,305 次裡有 5,915 次(57%)是 301。其中 4,736 次是網址結尾沒有 [/] 的請求,WordPress 以 301 導向加上 [/] 的網址,同一篇文章又被請求一次。
4️⃣ robots.txt 設定:訓練用與搜尋用的 token
robots.txt 適合處理自動收集的訓練用與搜尋用機器人,但不適合使用者提問時才抓取頁面的機器人。OpenAI 與 Perplexity 的文件說明,robots.txt 規則可能不適用於 ChatGPT-User 與 Perplexity-User 的請求。
各公司的 token 依用途分開,依 OpenAI 文件,封鎖一個 token 不會影響其他 token 的設定。以下是從各公司官方文件確認的 token。
| robots.txt token | 公司 | 用途 | 封鎖時(官方文件) |
|---|---|---|---|
| GPTBot | OpenAI | 模型訓練收集 | 不要用於訓練的訊號 |
| OAI-SearchBot | OpenAI | ChatGPT 搜尋 | 從 ChatGPT 搜尋回答中排除(仍可能以導覽連結出現) |
| ChatGPT-User | OpenAI | 使用者請求 | robots.txt 規則可能不適用 |
| ClaudeBot | Anthropic | 模型訓練收集 | 之後的資料排除在訓練資料外 |
| Claude-SearchBot | Anthropic | 改善搜尋品質 | 搜尋結果中的曝光可能減少 |
| Claude-User | Anthropic | 使用者請求 | 不會為使用者問題抓取頁面 |
| PerplexityBot | Perplexity | 搜尋(非訓練) | 從搜尋結果中排除 |
| Perplexity-User | Perplexity | 使用者請求 | 大致不遵守 robots.txt |
| Google-Extended | Gemini 訓練 · grounding | 不影響 Google 搜尋曝光 · 排名 | |
| Applebot-Extended | Apple | 基礎模型訓練 | 不影響 Apple 搜尋曝光 |
| meta-externalagent | Meta | AI 模型訓練等 | 以 Disallow 封鎖(文件範例) |
Google-Extended 與 Applebot-Extended 不是另外收集的機器人,而是只在 robots.txt 中使用的 token。收集仍由既有的 Google 與 Apple 爬蟲進行,這些 token 只決定收集到的內容能否用於訓練 AI 模型。
只拒絕訓練用收集、仍保留 AI 搜尋曝光的 robots.txt 如下;OpenAI、Perplexity 與 Meta 的文件說明,變更最多可能需要 24 小時才會生效。
# 拒絕訓練用收集
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: Applebot-Extended
Disallow: /
User-agent: meta-externalagent
Disallow: /
# 允許 AI 搜尋用機器人
User-agent: OAI-SearchBot
Allow: /
User-agent: Claude-SearchBot
Allow: /
User-agent: PerplexityBot
Allow: /Nginx + Apache 伺服器目前的 robots.txt 沒有指名 AI 機器人的行。
curl -s https://example.com/robots.txt# 適用於所有搜尋引擎機器人
User-agent: *
# 封鎖管理頁面(安全)
Disallow: /wp-admin/
# 允許管理功能中的 ajax 通訊(正常運作必須)
Allow: /wp-admin/admin-ajax.php
# 新增:封鎖垃圾搜尋結果(保護 SEO)
Disallow: /search/
Disallow: /?s=
# 指出網站地圖位置(加快索引)
Sitemap: https://example.com/sitemap_index.xml在沒有 AI 機器人行的狀態下,14 天中公開範圍的 GPTBot 請求 2,546 次都沒有 403,以 200 回應 2,090 次、301 回應 432 次。同一期間,來源記錄中以公開範圍計算的 robots.txt 請求為 Googlebot 36 次、ClaudeBot 8 次、OAI-SearchBot 6 次,GPTBot 與 PerplexityBot 為 0 次。robots.txt 也一樣,若由前端快取回應,就不會留在來源記錄中。
5️⃣ 在 nginx 封鎖 AI 爬蟲與其限制
即使在 robots.txt 封鎖,不讀規則的請求仍會直接進到伺服器。在 nginx 中,用 [map] 在 UA 含有機器人名稱時把變數設為 1。
# http 區塊內 — UA 中有訓練用機器人名稱時為 1
map $http_user_agent $ai_train_bot {
default 0;
~*GPTBot/ 1;
~*ClaudeBot/ 1;
~*Bytespider 1;
~*CCBot/ 1;
}在 server 區塊中,該變數為 1 時傳回 403。
# server 區塊內
location / {
if ($fake_searchbot) {
return 403;
}
if ($ai_train_bot) {
return 403;
}
# 以下為既有設定
}以 UA 封鎖的方式只檢查名稱,所以同名的冒充請求會一起被擋,換個名稱就能通過。借用已允許的搜尋用機器人名稱的請求,必須與公開 IP 範圍比對才能濾掉。
要允許 OAI-SearchBot、只拒絕從範圍外來的同名請求,就用 [geo] 把公開範圍做成變數,再與 UA 一起比對。
# http 區塊內 — OAI-SearchBot 公開範圍(放入整個 searchbot.json,以下只列兩行)
geo $oai_search_net {
default 0;
104.210.140.128/28 1;
135.234.64.0/24 1;
}
map $http_user_agent:$oai_search_net $fake_searchbot {
default 0;
~*OAI-SearchBot/.*:0$ 1;
}前端有 CDN 或代理伺服器時,[geo] 看到的是中介伺服器的位址,所以要先用 real_ip 還原真實 IP 再比對。Anthropic 文件說明,以 IP 位址封鎖也會讓機器人無法讀取 robots.txt,拒絕訊號可能無法正確傳達。
設定沒有放進運作中的伺服器,只用測試用設定檔檢查語法。
nginx -t -p ./ -c nginx-test/nginx.confnginx: the configuration file ./nginx-test/nginx.conf syntax is ok
nginx: configuration file ./nginx-test/nginx.conf test is successful設定範例只檢查了語法,所以沒有確認 403 回應;以 14 天記錄來看,掛著 OAI-SearchBot 名稱的 3,937 次請求中,有 2,347 次來自公開範圍外的冒充群組。
6️⃣ 向 AI 爬蟲收費的方式:Pay per crawl 與 Web Bot Auth
Pay per crawl 是 Cloudflare AI Crawl Control 的功能,讓網站擁有者為每個區域設定價格,對每次 AI 爬蟲請求收費。依 2026 年 10 月 18 日確認的官方文件,目前為非公開測試版,由 Cloudflare 以代理銷售者(Merchant of Record)處理付款。
以請求標頭送出付費意願的爬蟲會收到 200 回應,其他爬蟲則收到含有價格的 [402 Payment Required] 回應。若以 WAF 或 Bot Management 封鎖同一個爬蟲,封鎖規則優先於收費。
想付費的爬蟲必須以 Web Bot Auth 證明自己的身分。Web Bot Auth 是由機器人以 Ed25519 金鑰為請求簽章,並把公開金鑰放在 [/.well-known/http-message-signatures-directory] 位址,讓接收方驗證簽章的方式。
簽章透過 [Signature-Agent]、[Signature-Input]、[Signature] 三個標頭傳遞,以密碼學簽章取代 IP 範圍確認機器人。來源伺服器的預設存取記錄格式不記錄請求標頭,因此沒有確認 14 天內進來的 AI 爬蟲請求是否帶有簽章。
14 天中從公開 IP 範圍確認的 AI 爬蟲請求 18,605 次,相當於同一期間 Googlebot 與 bingbot 公開範圍請求 24,022 次的 77%。是否在 robots.txt 加入訓練用 token,要以排除冒充後的數字判斷;在每週記錄統計中加上公開範圍比對,就能確認其趨勢。
🔢 FAQ & 推薦內容
ℹ️ 聯盟行銷說明
本站內容包含聯盟行銷連結。訪客透過這些連結購買商品或服務時,本站會從賣家獲得佣金。在這個過程中,購買者支付的金額(遇到活動折扣時金額會降低↓)並不會因此提高。刊登的價格、折扣與庫存資訊以撰寫當時為準,可能與實際情況不同,購買前請向賣家做最後確認。商品的挑選與評價依本站自訂的標準撰寫,是否支付佣金不會影響介紹順序或評價內容。



