AI 爬蟲的 user agent 與 IP 範圍:GPTBot、ClaudeBot、PerplexityBot 等

發布於

簡短回答

GPTBot 以包含 GPTBot/1.4; +https://openai.com/gptbot 的 user agent 表明身分,而 OpenAI、Anthropic、Perplexity、Google、Microsoft、Apple 與 Common Crawl 都會公布一份 JSON 清單,列出其爬蟲使用的 IP 範圍。只有兩者都相符時,請求才是真的:user agent 指名該爬蟲,且來源 IP 在該廠商的清單中;若是 Googlebot、bingbot、Applebot 與 CCBot,也可以通過反向與正向 DNS 檢查。單憑 user agent 什麼也證明不了,因為任何人都能送出它。

當你在日誌中看到 GPTBot 或 ClaudeBot,或想設定一條讓 AI 搜尋爬蟲通過的防火牆規則時,你需要兩樣東西:每個爬蟲送出的確切字串,以及證明請求確實來自它所宣稱公司的方法。以下是各廠商目前公布的字串、每家的官方 IP 清單或 DNS 驗證方式,以及兩個可以用來檢查位址的指令碼。

本頁內容
  1. GPTBot、ClaudeBot、PerplexityBot 與其他 AI 爬蟲的 user agent 字串是什麼?
  2. 哪個爬蟲負責什麼?哪些名稱只是 robots.txt 標記?
  3. AI 爬蟲廠商在哪裡公布它們的 IP 範圍?
  4. 如何用官方爬蟲清單檢查某個 IP 位址?
  5. 如何用反向 DNS 驗證 Googlebot、bingbot 或 Applebot?
  6. 為什麼只檢查 user agent 不足以辨識 GPTBot?
  7. AISeeWhy 如何協助驗證 AI 爬蟲流量?

GPTBot、ClaudeBot、PerplexityBot 與其他 AI 爬蟲的 user agent 字串是什麼?

以下內容複製自各廠商自己的文件。OpenAI 與 Perplexity 註明版本號可能會變更,Google 與 Microsoft 會在 W.X.Y.Z 的位置放入目前的瀏覽器版本,Apple 則表示偶爾會更新瀏覽器部分。請比對爬蟲標記,例如 GPTBot 或 bingbot,而不是整個字串。

# OpenAI (version numbers may change)
GPTBot:          Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; GPTBot/1.4; +https://openai.com/gptbot
OAI-SearchBot:   Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.4; +https://openai.com/searchbot
ChatGPT-User:    Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot
OAI-AdsBot:      Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; OAI-AdsBot/1.0; +https://openai.com/adsbot

# Perplexity
PerplexityBot:   Mozilla/5.0 (compatible; PerplexityBot/1.0; +https://perplexity.ai/perplexitybot)
Perplexity-User: Mozilla/5.0 (compatible; Perplexity-User/1.0; +https://perplexity.ai/perplexity-user)

# Google (W.X.Y.Z is the current Chrome version)
Googlebot Smartphone: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Googlebot Desktop:    Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/W.X.Y.Z Safari/537.36
Googlebot Desktop:    Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

# Microsoft Bing (W.X.Y.Z is the current Edge version)
bingbot desktop: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/W.X.Y.Z Safari/537.36
bingbot:         Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
bingbot mobile:  Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)

# Apple (the browser part changes from time to time)
Applebot desktop: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15 (Applebot/0.1; +http://www.apple.com/go/applebot)
Applebot mobile:  Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1 (Applebot/0.1; +http://www.apple.com/go/applebot)

# Common Crawl
CCBot:           CCBot/2.0 (https://commoncrawl.org/faq/)

# Anthropic and Meta: match the token, see the notes below
ClaudeBot, Claude-SearchBot, Claude-User
meta-externalagent/1.1, meta-webindexer/1.1, meta-externalfetcher/1.1

Anthropic 的說明文章列出了 ClaudeBot、Claude-SearchBot 與 Claude-User,但沒有提供完整的 user agent 字串,所以請比對這些標記。Meta 的爬蟲頁面列出的字串以上面的標記開頭,後面接著它的文件連結,並表示你在日誌中看到的字串可能略有不同。

哪個爬蟲負責什麼?哪些名稱只是 robots.txt 標記?

有兩個名稱永遠不會出現在你的日誌中。Google-Extended 是一個 robots.txt 標記,控制 Google 檢索的內容能否用於 Gemini 模型與 grounding;Google 表示它不影響是否收錄於 Google 搜尋。Applebot-Extended 用 Apple 的話來說,是一個不會檢索網頁的次要 user agent;它只決定 Apple 可以如何使用 Applebot 收集的資料。自稱是這兩者之一的請求都不是真的。

AI 爬蟲廠商在哪裡公布它們的 IP 範圍?

大多數廠商都以相同的格式公布 JSON 檔案:一個 prefixes 陣列,其中的物件含有 ipv4Prefix 或 ipv6Prefix,另外還有一個 creationTime,告訴你檔案有多新。

如何用官方爬蟲清單檢查某個 IP 位址?

這個指令碼會載入每份清單,並回報哪一份包含該位址。它只需要 Python 3,並支援 IPv4 與 IPv6。

python3 - 20.171.206.5 <<'EOF'
import ipaddress, json, sys, urllib.request

LISTS = {
    "GPTBot": "https://openai.com/gptbot.json",
    "OAI-SearchBot": "https://openai.com/searchbot.json",
    "ChatGPT-User": "https://openai.com/chatgpt-user.json",
    "ClaudeBot, Claude-SearchBot, Claude-User": "https://claude.com/crawling/bots.json",
    "PerplexityBot": "https://www.perplexity.ai/perplexitybot.json",
    "Perplexity-User": "https://www.perplexity.ai/perplexity-user.json",
    "Googlebot": "https://developers.google.com/static/crawling/ipranges/common-crawlers.json",
    "bingbot": "https://www.bing.com/toolbox/bingbot.json",
    "Applebot": "https://search.developer.apple.com/applebot.json",
    "CCBot": "https://index.commoncrawl.org/ccbot.json",
}

ip = ipaddress.ip_address(sys.argv[1])
found = False
for name, url in LISTS.items():
    req = urllib.request.Request(url, headers={"User-Agent": "ip-list-check"})
    try:
        prefixes = json.load(urllib.request.urlopen(req, timeout=15))["prefixes"]
    except Exception as err:
        print(f"{name}: list not loaded ({err})")
        continue
    nets = [ipaddress.ip_network(p.get("ipv4Prefix") or p.get("ipv6Prefix")) for p in prefixes]
    if any(ip in net for net in nets if net.version == ip.version):
        print(f"{ip} is listed for {name}")
        found = True
if not found:
    print(f"{ip} is not in any of these lists")
EOF

這些清單會變動。每個檔案都有自己的 creationTime,Perplexity 建議自動更新防火牆規則,Bing 也要求每天更新它的清單。如果你在防火牆中使用這些清單,請定期擷取,而不是只複製一次。

如何用反向 DNS 驗證 Googlebot、bingbot 或 Applebot?

Google、Microsoft、Apple 與 Common Crawl 都記載了相同的兩步驟檢查:查詢 IP 位址對應的名稱,確認它以廠商的網域結尾,再查詢這個名稱,確認它傳回同一個 IP。兩個步驟都很重要,因為掌控某個 IP 範圍的人可以隨意設定反向 DNS 名稱,卻無法讓廠商的網域指回這個 IP。

verify_crawler_ip() {
  ip="$1"
  name=$(host "$ip" | awk '/domain name pointer/ {print $NF}' | sed 's/\.$//' | head -n 1)
  if [ -z "$name" ]; then echo "$ip: no reverse DNS name"; return 1; fi
  case "$name" in
    *.googlebot.com|*.search.msn.com|*.applebot.apple.com|*.crawl.commoncrawl.org) ;;
    *) echo "$ip -> $name: not a crawler hostname"; return 1 ;;
  esac
  if host "$name" | grep -qwF -- "$ip"; then
    echo "$ip -> $name -> $ip: verified"
  else
    echo "$ip -> $name: forward lookup does not return $ip"; return 1
  fi
}

verify_crawler_ip 66.249.66.1
# 66.249.66.1 -> crawl-66-249-66-1.googlebot.com -> 66.249.66.1: verified

Google 的各類爬蟲接受 googlebot.com、google.com 與 googleusercontent.com;上面的函式只接受 googlebot.com,也就是 Google 範例中 Googlebot 本身使用的網域。Google 的其他爬蟲與擷取工具請使用它的 JSON 清單。DNS 查詢需要時間,所以請在檢視日誌時執行,或把結果快取起來,而不要對每個即時請求都執行。

為什麼只檢查 user agent 不足以辨識 GPTBot?

user agent 是由用戶端自己決定的標頭,所以任何人都能送出 GPTBot 或 Googlebot。Common Crawl 警告有些爬蟲會冒充 CCBot,Bing 也發布了一份指南,教你檢查自稱 bingbot 的流量是否真的來自 Bing。要可靠地辨識 GPTBot,就必須兩者都檢查:user agent 中的標記,以及來源 IP 是否在 gptbot.json 中。帶有該標記卻來自清單外位址的請求就是冒充者,封鎖它不會影響 OpenAI。

反過來的情況也會發生。如果你的防火牆只看 user agent 放行,冒充者就能進來;如果只看 IP 範圍放行,來自該廠商網路的任何代理程式都會得到相同待遇,即使是你本來想封鎖的那個。兩者都比對,才是可靠的規則。

AISeeWhy 如何協助驗證 AI 爬蟲流量?

免費的 AISeeWhy AI 爬蟲 IP 檢查無需帳戶,就能告訴你某個 IP 位址是否屬於 GPTBot 或其他 AI 爬蟲。免費的網站檢查接著會以 16 個 AI 與搜尋爬蟲的身分,連同真實瀏覽器一起請求你的頁面,讓你看到真正的爬蟲會收到什麼。

免費工具

下一步

本文提到的爬蟲

常見問題

GPTBot 的 user agent 是什麼?

OpenAI 公布的是 Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; GPTBot/1.4; +https://openai.com/gptbot,並註明版本可能會變更。請比對 GPTBot,並用 https://openai.com/gptbot.json 確認 IP。

OAI-SearchBot 的 user agent 是什麼?

一個類似 Chrome 的字串,結尾是 compatible; OAI-SearchBot/1.4; +https://openai.com/searchbot。它的位址列在 https://openai.com/searchbot.json 中。OpenAI 用它讓網站出現在 ChatGPT 搜尋中,這和 GPTBot 的工作不同。

Anthropic 有公布 ClaudeBot 的 IP 位址嗎?

有。Anthropic 提供了 https://claude.com/crawling/bots.json 的連結,並表示來源 IP 在這份清單上,就代表爬蟲來自 Anthropic。它的說明文章列出了機器人標記,但沒有完整的 user agent 字串。

我能在日誌中看到 Google-Extended 或 Applebot-Extended 嗎?

不能。兩者都是 robots.txt 標記,不是爬蟲。Google 與 Apple 以 Googlebot 和 Applebot 擷取頁面,只用這些標記來決定內容可以如何用於 AI。

bingbot 的 IP 位址清單在哪裡?

Bing 把它公布在 https://www.bing.com/toolbox/bingbot.json,並要求你每天更新。它自己的指南建議使用反向與正向 DNS 檢查,名稱必須以 search.msn.com 結尾。

資料來源

更多文章