- Python's urllib.robotparser is a fast first check for AI crawler rules, but it is not the parser any crawler uses. In our seven file test it ignored a wildcard rule, applied rules in file order and read only the first of two groups for the same bot.
- OpenAI documents separate bots for search, training and user actions. As of the page we read in October 2026, OAI-SearchBot and GPTBot obey robots.txt, and ChatGPT-User may not.
- Use the parser to catch obvious mistakes, then confirm with the vendor's documentation and your server logs. A parser result is a hint, not proof of what a crawler will do.
Can you test robots.txt for AI crawlers with Python?
Yes. Python ships with urllib.robotparser, which reads a robots.txt file and answers a simple question: may this user agent fetch this URL? It is fast, free and good for catching obvious mistakes such as a stray Disallow slash. It is also a simplified parser, and in our tests it gave answers that a real crawler would not always give. This article shows what we tested, what came out, and how to use the tool without being fooled.
We ran this on 24 October 2026 with Python 3.11.15. We wrote seven small robots.txt files, each built to test one behaviour, and ran 17 checks across them. We did not test a live site, and we did not look at server logs. Everything below is about the parser, not about what ChatGPT, Perplexity or Google does at crawl time. If you want the rules for what to allow, read which AI crawlers to allow in robots.txt first, then come back to test your file.
Which AI bots should you test?
OpenAI's crawler overview, which we read in October 2026, lists four user agents. OAI-SearchBot is used to surface sites in ChatGPT search features. GPTBot crawls content that may be used to train generative AI foundation models. its ads bot, listed as OAI AdsBot, checks pages submitted as ads on ChatGPT. ChatGPT-User handles user initiated actions in ChatGPT and Custom GPTs.
The page makes three points that matter for testing. Each setting is independent, so allowing one does not allow another. OAI-SearchBot and GPTBot obey robots.txt. For ChatGPT-User, the page says that because actions are user initiated, robots.txt rules may not apply. It also says a robots.txt update can take about 24 hours to take effect for search results. That means a parser test tells you what the file says, not what the system has already picked up.
| User agent | Does robots.txt apply? | |
|---|---|---|
| OAI-SearchBot | Surfaces websites in ChatGPT search features | Yes. Opting out means not shown in ChatGPT search answers |
| GPTBot | Crawls content that may be used to train foundation models | Yes. Disallowing signals content should not be used for training |
| User initiated actions in ChatGPT and Custom GPTs | Rules may not apply, per the page | |
| OAI AdsBot | Checks safety of pages submitted as ads | Not stated on the page we read |
What did we test, and what happened?
Each test is small on purpose. Here are the seven files and the results, in the order we ran them.
| Test | File in plain words | Result in Python 3.11.15 |
|---|---|---|
| A | All bots blocked from /private/. GPTBot blocked from everything | GPTBot blocked on the blog and private paths. OAI-SearchBot, ChatGPT-User and Googlebot allowed on the blog, blocked on /private/ |
| B | Disallow /blog/ first, then Allow /blog/public/ | A public page was reported blocked |
| C | Allow /blog/public/ first, then Disallow /blog/ | The same public page was reported allowed |
| D | Disallow /*.pdf$ (wildcard and end anchor) | A PDF URL was reported allowed. An HTML URL was allowed |
| E | Two separate GPTBot groups, one blocking /a/, one blocking /b/ | /a/ blocked, /b/ allowed |
| F | Group written as gptbot in lower case, disallow everything | GPTBot reported blocked, so names are not case sensitive |
| G | Block all bots, then give OAI-SearchBot its own group that allows everything | OAI-SearchBot allowed, GPTBot blocked |
Where does the parser mislead you?
Rule order changes the answer (tests B and C)
In test B the Disallow came first and the more specific Allow came second. The parser reported the public page blocked. Reverse the two lines and it reports the page allowed. So the parser applies the first rule that matches, in file order. Google documents a different approach for its own crawlers, where the most specific matching rule wins, and the standard published as RFC 9309 describes a longest match approach. We did not read the RFC again during this test, so check it before you rely on our summary. The practical point stands: the same file can pass in one parser and fail in another, so do not treat a single result as final.
Wildcards are ignored (test D)
The rule that blocks every PDF uses a star and a dollar sign. Major crawlers support those characters. Python's parser read the rule literally, so it never matched a real PDF path, and it reported the PDF as allowed. If your file blocks file types with wildcards, a Python test will say your PDFs are open when a real crawler may treat them as closed.
Only the first group is read (test E)
Test E repeated the same user agent in two groups. The parser blocked the path in the first group and allowed the path in the second. Many people write robots.txt files by appending a new block for the same bot after an old one, for example when a plugin and a person both edit the file. A parser that stops at the first group would report a safe state that a more standard parser would not. We are describing the standard library behaviour we saw, not claiming how any particular crawler merges groups.
What does a safe testing routine look like?
- Fetch your live robots.txt and save a dated copy. Do not test an edited local copy and assume it is deployed.
- Write down the intended outcome for each bot and key path in a small table: allowed or blocked, and why.
- Run the Python check for each bot and path. Flag every result that differs from your table.
- For any flagged result, remove wildcards and duplicate groups where you can, put specific Allow lines before broader Disallow lines, and test again.
- Wait for the vendor's stated delay. OpenAI says about 24 hours for search. Then check the vendor documentation and your server logs for the bot's visits.
- Repeat after any CMS, plugin or CDN change, because those often rewrite robots.txt.
How does this fit with the other ways to check access?
The parser answers one question: what does this file permit for this name? It does not tell you whether a firewall or CDN is blocking the bot before robots.txt is even read, whether the pages render for a crawler that does not run scripts, or whether your sitemap lists the right URLs. For those, use the free AI Crawler Access Checker, and generate a clean file with the AI Crawler Robots.txt Generator. Our guide to GEO for JavaScript and headless sites covers the rendering side.
If you are still deciding which bots to allow, remember the trade off OpenAI describes. Blocking OAI-SearchBot means not appearing in ChatGPT search answers. Blocking GPTBot is a separate choice about training. They are independent, so make the decision for each on purpose.
What should you do next?
Open your robots.txt today and read it as a list of names and paths. Remove duplicate groups, avoid clever wildcards unless you need them, and write down your intended policy for search bots, training bots and user action bots. Then test it. If you would rather have the access fixes and the checks done for you, the crawler access check is part of Week 1 of the GEO Pilot, and the fixes follow in Week 2.








