Sub topic 12
Reading logs to see who is crawling
Your robots.txt file states a policy. Your access logs show what crawlers actually do. This chapter assumes you have shell access to your web server logs (or a log export from your host or CDN) and can read basic Python. You will count AI crawler visits, check whether they fetch robots.txt, find requests to paths you disallowed, and separate real crawlers from impostors.
What a log line gives you
Most servers write the "combined" log format by default. Each request is one line:
203.0.113.7 - - [29/Nov/2026:09:41:12 +0000] "GET /articles/guide HTTP/1.1" 200 18342 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; GPTBot/1.1; +https://openai.com/gptbot"Four fields matter for crawler analysis:
- The client IP address (first field).
- The request path (inside the quoted request).
- The status code (200, 403, 404 and so on).
- The User-Agent (the last quoted field).
The User-Agent is the claim a client makes about itself. The IP address is much harder to fake. Good log analysis uses both.
Which crawlers appear in logs
Not every token in your robots.txt shows up as a User-Agent in your logs. Tokens fall into two groups:
| Token | Appears in logs under that name? | Notes |
|---|---|---|
| GPTBot, OAI-SearchBot, ChatGPT-User | Yes | Each fetches pages with its own user agent. |
| ClaudeBot, PerplexityBot, CCBot | Yes | Look for the token inside the full User-Agent string. |
| Google-Extended | No | A control token only. Fetching is done by Google's normal crawlers, so you see Googlebot. |
| Applebot-Extended | No | A control token only. Fetching is done by Applebot. |
A first count with grep
The quickest view is a count per crawler. This pipeline matches lines that contain a known token, extracts the token, and ranks the totals:
# Count requests per AI crawler in a combined-format access log
grep -Ei 'GPTBot|OAI-SearchBot|ChatGPT-User|ClaudeBot|PerplexityBot|CCBot' access.log \
| grep -Eio 'GPTBot|OAI-SearchBot|ChatGPT-User|ClaudeBot|PerplexityBot|CCBot' \
| sort | uniq -c | sort -rnThe first grep filters the lines. The second uses -o to print only the matched token, one per match. sort | uniq -c counts them, and the final sort -rn puts the busiest crawler first.
Two limits apply. A line mentioning two tokens would be counted twice, which is rare. The -i flag also makes gptbot and GPTBot count the same, which is what you want here.
Rotated logs are often compressed. Use zcat access.log.*.gz | grep ... to include them. A single day of data can mislead, because crawlers visit in bursts, so look at a week or more.
Looking at status codes
Counts alone do not show how your server responded. Pull the status code for one crawler with awk. In combined format, field 9 is the status when fields are split on whitespace:
# Status code breakdown for GPTBot requests
grep -i 'GPTBot' access.log | awk '{print $9}' | sort | uniq -c | sort -rnHow to read the result:
- Mostly 200: the crawler is fetching content.
- Mostly 403: your server-side block is working (see the enforcement chapter).
- Many 404: the crawler follows old links or guesses URLs. This is a sitemap and redirect problem, not a crawler problem.
- 429 or 5xx: the crawler is straining your server. Rate limiting or a
Crawl-delay-style approach may be needed, though not every crawler honors it.
Checking compliance with a script
Shell one-liners get awkward once you want per-crawler rules. A short Python script can answer three questions at once:
- How many requests did each crawler make?
- Did each crawler fetch
/robots.txtat all? - Did any crawler request a path you disallowed for it?
import re
import sys
from collections import Counter
LINE = re.compile(
r'^(\S+) \S+ \S+ \[[^\]]+\] "(\S+) (\S+) [^"]*" (\d{3}) \S+ "[^"]*" "([^"]*)"$'
)
BOTS = ["GPTBot", "OAI-SearchBot", "ChatGPT-User", "ClaudeBot", "PerplexityBot", "CCBot"]
# Paths each crawler is disallowed from, matching your robots.txt
DISALLOWED = {
"GPTBot": ("/members/", "/drafts/"),
}
def identify(user_agent):
lowered = user_agent.lower()
for bot in BOTS:
if bot.lower() in lowered:
return bot
return None
def main(path):
requests = Counter()
robots_fetches = Counter()
violations = Counter()
with open(path, encoding="utf-8", errors="replace") as handle:
for raw in handle:
match = LINE.match(raw.strip())
if not match:
continue
ip, method, url, status, user_agent = match.groups()
bot = identify(user_agent)
if bot is None:
continue
requests[bot] += 1
if url.split("?")[0] == "/robots.txt":
robots_fetches[bot] += 1
for prefix in DISALLOWED.get(bot, ()):
if url.startswith(prefix) and status != "403":
violations[(bot, prefix)] += 1
print("Requests per crawler:")
for bot, count in requests.most_common():
print(f" {bot}: {count} (robots.txt fetches: {robots_fetches[bot]})")
print("Requests to disallowed paths that were not blocked by the server:")
if not violations:
print(" none")
for (bot, prefix), count in sorted(violations.items()):
print(f" {bot} -> {prefix}: {count}")
if __name__ == "__main__":
main(sys.argv[1])Run it with python3 crawlers.py access.log. Lines that do not match the combined format are skipped, so a custom log format needs a different pattern.
The script skips violations that returned 403. A 403 means the request was made but your server refused it. That is still worth knowing, since it shows the crawler ignored robots.txt, but it caused no exposure. If you want to count those too, remove the status check.
Interpreting what you find
Three patterns come up often:
- A crawler with requests but zero robots.txt fetches. In a short window this can be normal, because crawlers cache robots.txt, often for up to a day. Over weeks it suggests the crawler ignores the file.
- Hits on disallowed paths shortly after you changed robots.txt. Crawlers re-read the file on their own schedule. Allow a day or two before treating this as non-compliance.
- A "GPTBot" from an address that is not OpenAI's. The User-Agent is only text. Anyone can send it, including scrapers that hope to be treated as a trusted bot.
Verifying that a crawler is genuine
Operators publish ways to check their crawlers:
- OpenAI publishes lists of IP ranges for its crawlers, in machine-readable form.
- Google documents a reverse DNS check for Googlebot: look up the hostname for the IP, confirm it ends in
googlebot.comorgoogle.com, then resolve that hostname forward and confirm it returns the same IP. - Other operators vary. Some publish IP lists, some publish only a User-Agent format, and some publish nothing verifiable.
You can run the reverse and forward lookup for any IP:
# Reverse lookup, then forward lookup of the name that came back
host 66.249.66.1
host crawl-66-249-66-1.googlebot.comThe forward result must match the original IP. Checking only the reverse lookup is not enough, because the owner of an IP range controls its reverse DNS and can set any name.
For operators that publish IP ranges, download the current list and compare it with the IPs in your logs. Refresh it regularly, since the ranges change.
Edge cases that distort the numbers
- CDN and proxy logs. If a CDN sits in front of your server, your origin log shows the CDN's IP, not the crawler's. Read the forwarded-client header your CDN sets, or use the CDN's own logs, before you verify IPs.
- Cached responses. Requests served entirely by a CDN cache may never reach your origin log, so origin counts understate real crawler traffic.
- Mixed purposes under one company. ChatGPT-User fetches a page because a person asked for it in a chat. Its traffic follows user activity, not a crawl schedule, and it can spike when a page is shared widely.
- Version strings. User-Agent strings include version numbers such as
GPTBot/1.1. Match on the token, not the full string, so a version bump does not break your filters. - Case and substring matches.
CCBotis short enough to appear inside unrelated strings. If you see odd results, anchor the match with a slash, as inCCBot/.
Keeping a routine
A useful routine is small. Once a week, run the count and the compliance script. Note any crawler that is new, any whose volume jumped, and any hit on a disallowed path. Feed those findings back into your policy, which the next chapter covers.
Exercise
Your robots.txt blocks Google-Extended. A colleague greps the access log for "Google-Extended" and finds no matches. They conclude the block is working and that Google has stopped fetching the site. What is wrong with this reasoning, and what should they look at instead?
Show answer
Google-Extended is a robots.txt control token, not a user agent that fetches pages, so it never appears in access logs whether blocked or not. Google's normal crawlers (Googlebot) keep fetching the site and are not affected by this token. The empty search proves nothing. To check Google traffic they should search for Googlebot and verify the IPs with reverse and forward DNS. They can confirm the block is in place by reading the live robots.txt with curl, since the effect of Google-Extended is on how Google uses content, which logs cannot show.
Exercise
The compliance script reports that GPTBot made 40 requests to /drafts/ over the last week, and all returned 200. List two checks you would make before concluding that OpenAI's crawler ignores your robots.txt, and one action to take if the conclusion holds.
Show answer
First, check the source IPs of those requests against OpenAI's published IP ranges, because the User-Agent may be spoofed by another client. Second, check when the Disallow rule for /drafts/ was deployed and whether it was live at the time of the requests, since crawlers cache robots.txt and a recent change takes time to be honored. If the requests come from OpenAI's ranges after the rule was live, add a server-side rule (for example the nginx User-Agent map returning 403, or an IP block) so that the path is refused regardless of crawler behavior.