GrepBoard/매뉴얼
51 편 ·

robots.txt 가 AI 크롤러를 막는지 Python 으로 검사하기

·Python 3.12.3 (urllib.robotparser) · OpenAI·Anthropic 공식 문서 2026-10-19 확인·8 단계

GPTBot 을 막았는데 ChatGPT 검색에는 나오고 싶다면? robots.txt 를 Python 표준 라이브러리로 읽어 학습용·검색용·사용자 요청용 봇별 허용 여부를 표로 뽑습니다.

User-agent: GPTBot 에 Disallow: / 를 넣었다고 AI 서비스 전체가 막히는 것은 아닙니다. 회사마다 봇이 역할별로 나뉘어 있어서, 어느 봇이 어떤 규칙을 받는지 직접 확인해야 합니다.

[1] 봇의 역할부터 공식 문서로 확인합니다. OpenAI 는 크롤러 문서에서 이렇게 구분합니다.

봇문서의 설명
GPTBot"Disallowing GPTBot indicates a site's content should not be used in training generative AI foundation models."
OAI-SearchBot"OAI-SearchBot is used to surface websites in search results in ChatGPT's search features."
ChatGPT-User"ChatGPT-User is not used for crawling the web in an automatic fashion."

ChatGPT-User 는 사용자가 시킨 동작이라 문서에 "robots.txt rules may not apply" 라고 적혀 있습니다. 아래 검사에서 ChatGPT-User 가 BLOCK 으로 나와도 실제로 막힌다는 보장은 아닙니다.

[2] Anthropic 은 고객지원 문서에서 세 봇을 소개합니다. ClaudeBot 은 학습에 쓰일 수 있는 웹 콘텐츠를 수집하고, Claude-User 는 사용자가 Claude 에게 질문할 때 페이지를 가져오며, Claude-SearchBot 은 검색 결과 품질을 높이는 용도입니다. 봇마다 User-agent 줄과 Disallow: / 로 따로 막습니다. 하위 도메인마다 robots.txt 를 따로 둬야 하고, IP 대역으로 막는 방식은 봇이 robots.txt 를 읽지 못하게 할 수 있어 권하지 않는다고 합니다.

[3] 검사할 샘플 robots.txt 를 만듭니다. 학습용(GPTBot · ClaudeBot)만 막고 검색용 두 봇은 허용하는 구성입니다. 두 User-agent 줄을 붙여 쓰면 규칙 하나를 함께 받습니다.

robots.txt
User-agent: *Disallow: /admin/ User-agent: GPTBotDisallow: / User-agent: ClaudeBotDisallow: / User-agent: OAI-SearchBotUser-agent: Claude-SearchBotAllow: /

[4] 표준 라이브러리 urllib.robotparser 로 봇 목록을 돌리는 스크립트를 만듭니다. 파일을 읽어 parse() 에 넘기므로 네트워크를 쓰지 않습니다.

check_ai_robots.py
#!/usr/bin/env python3"""usage: check_ai_robots.py robots.txt URL_PATH"""import sysfrom urllib.robotparser import RobotFileParserBOTS = ["GPTBot", "OAI-SearchBot", "ChatGPT-User", "ClaudeBot", "Claude-SearchBot", "Claude-User"]rp = RobotFileParser()rp.parse(open(sys.argv[1], encoding="utf-8").read().splitlines())path = sys.argv[2]for bot in BOTS:    print(f"{bot:<18} {'allow' if rp.can_fetch(bot, 'https://example.com' + path) else 'BLOCK'}")

[5] 일반 글 경로를 검사합니다.

console
$ python3 -I check_ai_robots.py robots.txt /blog/post/GPTBot             BLOCKOAI-SearchBot      allowChatGPT-User       allowClaudeBot          BLOCKClaude-SearchBot   allowClaude-User        allow

학습용 두 봇만 막혔고 검색용·사용자 요청용은 열려 있습니다.

[6] /admin/ 경로도 봅니다. * 규칙은 이름이 따로 없는 봇에만 적용되므로, 전용 그룹이 있는 봇은 그 그룹만 따릅니다.

console
$ python3 -I check_ai_robots.py robots.txt /admin/xGPTBot             BLOCKOAI-SearchBot      allowChatGPT-User       BLOCKClaudeBot          BLOCKClaude-SearchBot   allowClaude-User        BLOCK

OAI-SearchBot 과 Claude-SearchBot 은 Allow: / 그룹이 있어 /admin/ 도 허용으로 나왔습니다. 관리자 경로를 막으려면 두 봇 그룹에도 Disallow: /admin/ 을 넣습니다.

[7] 이름 비교 방식을 알아 둡니다. Python 의 robotparser 는 User-agent 값이 검사하는 이름 안에 들어 있으면 그 그룹을 적용하는 부분 일치로 동작했습니다.

console
$ python3 - <<'PY'from urllib.robotparser import RobotFileParserrp = RobotFileParser(); rp.parse("User-agent: Claude\nDisallow: /".splitlines())for b in ["ClaudeBot", "Claude-SearchBot", "Claude-User", "GPTBot"]:    print(b, rp.can_fetch(b, "https://example.com/"))PYClaudeBot FalseClaude-SearchBot FalseClaude-User FalseGPTBot True

Claude 라는 느슨한 이름 하나가 세 봇을 모두 막은 결과입니다. 또 can_fetch() 에는 제품 이름(GPTBot)만 넣어야 합니다. Mozilla/5.0 (compatible; GPTBot/1.4; …) 전체 문자열을 넣었더니 이 샘플에서 True 가 나왔습니다. 로그의 UA 전체를 검사하려면 제품 이름을 먼저 뽑으세요.

[8] 고친 robots.txt 를 올린 뒤에는 시간을 둡니다. OpenAI 문서는 검색 결과에 반영되기까지 robots.txt 갱신 후 약 24시간이 걸릴 수 있다고 합니다.

#robots-txt#ai-crawler#seo#python