robots.txt and Web Scraping: How to Check Whether a Site Allows Scraping

Every well-run website publishes a short instruction sheet for bots at /robots.txt, and it spells out which sections automated visitors are asked to leave alone. Opening that sheet is where any scraping assessment should begin, yet it settles only part of the question. The file expresses a wish rather than enforcing anything, it grants no rights, and the operator's terms, its tolerance for request volume and the legal status of the data weigh just as heavily on the final decision.
Below we go through the file line by line, with extra care for the parts people misread most often: which rule wins when two overlap, how wildcards behave, what a 404 or 503 on the file means and which directives Google simply skips. You will also see a Python helper for testing addresses, how publishers single out AI crawlers in 2026, the other checks worth doing before the first request, and a reusable checklist at the end.
Proxies for responsible scraping
Spread permitted requests across stable IPs and see pages as users in your target country
What robots.txt Is and What It Is Not
The convention dates back to 1994; after almost three decades as an informal agreement it was written down by the IETF as RFC 9309 in September 2022. A crawler looks for it only in the root folder, and each copy governs a single origin, meaning one particular scheme, hostname and port. So shop.example.com keeps its own rules, independent of whatever www.example.com says.
Things the file is good for:
- naming URL paths that one specific bot, or bots in general, are asked to skip;
- pointing to sitemap files, which double as a ready list of pages the owner wants found;
- occasionally passing along informal hints, a crawl delay being the classic example.
Things people wrongly expect from it:
- enforcement: a program that never reads the file can still pull every page, since nothing on the server is locked;
- permission: an
Allowline grants nothing beyond what the terms, copyright and privacy rules already permit; - search visibility: keeping a URL out of Google results is the job of a
noindexmeta element or anX-Robots-Tagresponse header.
How to Read the File
Internally the document is a series of blocks. A block opens with at least one User-agent line naming the bots it addresses, followed by path rules that say Allow or Disallow. The sample below mixes the patterns you meet most often:
User-agent: *
Disallow: /cart/
Disallow: /search
Disallow: /*?sessionid=
Allow: /search/help
Crawl-delay: 5
User-agent: GPTBot
Disallow: /
User-agent: PartnerFeedBot
Allow: /
Sitemap: https://www.example.com/sitemap-index.xml| Directive in the sample | How a compliant bot interprets it |
|---|---|
User-agent: * | Fallback block, used by any bot that has no block of its own |
Disallow: /cart/ | Skip every address under the cart folder |
Disallow: /search | A prefix, so /search/, /search?q=x and even /searchable are excluded |
Disallow: /*?sessionid= | The asterisk stands for any run of characters |
Allow: /search/help | Carves an exception out of the excluded search area |
Crawl-delay: 5 | Informal request to wait five seconds between hits |
User-agent: GPTBot + Disallow: / | That bot is asked to stay away from the whole host |
Sitemap: | Sitemap location, valid regardless of the blocks around it |
Four points cause most misreadings:
- A bot follows exactly one block. It picks the block whose name matches it best and then disregards the asterisk block completely. That is why
PartnerFeedBotin the sample may open cart pages: its dedicated block permits everything. - Specificity beats position. If an
Allowand aDisallowboth fit a URL, RFC 9309 applies whichever pattern is longer, and anAllowtakes a tie. Where the lines sit in the file is irrelevant. - A dollar sign pins the end. With
Disallow: /*.pdf$, an address that finishes with.pdfis excluded, yet/file.pdf?v=2is not. - Paths respect letter case, while bot names are compared case-insensitively.

Directives Outside the Standard
RFC 9309 says nothing about Crawl-delay. Google disregards the line, whereas engines such as Bing and Yandex have historically taken it into account. For your own collector the number is still valuable, because it reveals the tempo the operator is comfortable with, and following it costs almost nothing. Clean-param and Host belong to Yandex and can safely be skipped by a general-purpose scraper.
When the File Is Missing or Broken
The RFC also covers failures while fetching the file itself:
- a 4xx status such as 404 means the rules are unavailable, so a bot may treat the host as unrestricted;
- a 5xx status or a dropped connection means the rules are unreachable, so a bot should behave as if every path were excluded until a later attempt succeeds;
- caching of a fetched copy should not exceed a day, apart from periods when a fresh copy cannot be obtained.
Parsers must also cope with files of at least 500 KiB. Google treats that figure as a hard ceiling and disregards anything past it.
How to Check robots.txt in Python
Python includes a ready-made parser in its standard library. The helper below reports whether your bot may request an address, plus any crawl delay and the listed sitemaps:
from urllib.robotparser import RobotFileParser
from urllib.parse import urlsplit
BOT_NAME = "AcmePriceWatch/1.2 (+https://acme.example/bot)"
BOT_TOKEN = "AcmePriceWatch"
def robots_verdict(page_url: str) -> dict:
parts = urlsplit(page_url)
rules = RobotFileParser()
rules.set_url(f"{parts.scheme}://{parts.netloc}/robots.txt")
rules.read()
return {
"allowed": rules.can_fetch(BOT_TOKEN, page_url),
"delay": rules.crawl_delay(BOT_TOKEN),
"sitemaps": rules.site_maps(),
}
print(robots_verdict("https://books.toscrape.com/catalogue/page-2.html"))Put the long BOT_NAME into your User-Agent header, so administrators can tell who is visiting and how to reach you, and evaluate rules against the short token. One caveat: the built-in module walks the rules top to bottom instead of applying the longest-pattern principle from RFC 9309, so a file with overlapping Allow and Disallow entries may get a different verdict. Scrapy ships with Protego as its default parser, which is designed to track the current specification more faithfully, and a dedicated library like that is the safer option for production crawlers.

AI Crawlers and robots.txt in 2026
From 2023 onward a growing number of publishers have written separate blocks aimed at AI bots. Tokens that turn up frequently are GPTBot and OAI-SearchBot from OpenAI, Anthropic's ClaudeBot, Google-Extended (a switch for Google's AI products rather than a distinct crawler), Applebot-Extended, CCBot from Common Crawl, PerplexityBot and Bytespider. Vendors rename agents and introduce new ones, so consult each company's own crawler page instead of copying lists from older posts.
Two further developments are worth tracking. In 2025 Cloudflare proposed a Content-Signal line through which a site can say, for instance, yes to search indexing and no to model training; it records a preference and sits outside RFC 9309. Separately, an IETF group is drafting shared terms for AI usage preferences. The practical rules stay the same: when you gather pages for a training corpus or a retrieval system, run your bot under its own name, obey blocks addressed to AI agents and count declared training preferences among the site's conditions. How such pipelines are put together is described in our article on AI web scraping.
Beyond robots.txt: What Else to Check
| Item | Where you find it | Why it matters |
|---|---|---|
| Terms of service | Footer pages titled Terms, Conditions of Use or Legal | They may forbid bots, systematic copying or commercial reuse |
| Official API or data feed | Developer, partner or API sections | A sanctioned channel, usually with documented quotas |
| Login requirement | Whether pages render for an anonymous visitor | Content behind an account is generally not fair game |
| Rate limits | 429 replies, Retry-After and quota headers | Show how much traffic the server accepts |
| Personal data | Names, contacts or profiles visible on pages | Triggers privacy duties: collect less, secure it, document the basis |
| Copyright and database rights | Nature of the material, jurisdiction | Republishing may be restricted even where downloading is tolerated |
Law in this area differs between countries and keeps shifting. Within the EU, the text and data mining exception lets rightsholders opt out by machine-readable means, and robots.txt is frequently named as one of them. American courts have reached mixed, fact-dependent conclusions on collecting public pages. Disregarding the file does not by itself make a project unlawful, and obeying it does not by itself make a project lawful. Anything commercial deserves a review by a lawyer familiar with the relevant jurisdiction. For the technical side of the blocks you may run into, see our guide on errors when parsing websites.

Pre-Scrape Checklist
- Download
/robots.txtfrom every host involved, subdomains included, and find the block your bot falls under. - Run your real URL patterns, query strings and all, through a parser.
- Search the terms for wording about bots, crawling, scraping or automated access.
- Find out whether an official API, bulk export or data licence exists.
- Make sure the pages render for a visitor who is not signed in.
- Note every kind of personal data on the pages and drop what you do not need.
- Start slow, follow any crawl delay and
Retry-Aftervalue, and run large jobs when traffic is low. - Announce your bot through a descriptive User-Agent that includes a contact link.
- During long runs, fetch the rules again at least every 24 hours.
- Record what you verified and on which date.
Where Proxies Fit In
A proxy never widens what an operator permits. In a well-behaved setup it solves practical problems: it spreads allowed traffic so no single address strains the server, lets you see pages the way visitors in a chosen country see them, and keeps lengthy jobs from collapsing on one IP. Open data that a site lets you collect usually works fine through datacenter proxies, while consumer platforms whose content varies by region respond better to residential addresses. Pointing a pool of IPs at paths the file excludes is precisely the behaviour this checklist exists to rule out. For configuration details, read our guide to proxies in web scraping and the broader introduction to web scraping.
robots.txt and scraping FAQ
Does robots.txt make scraping legal or illegal?
On its own it does neither. The file is a voluntary convention describing what the owner would like; the legal outcome turns on the terms of service, the kind of data and local law, though courts and EU copyright rules may weigh the file as evidence of the owner's intent.
What if a site has no robots.txt file?
A 404 on that address is read under the standard as the absence of crawl rules. Terms of service, privacy obligations and request limits still apply and need checking before you collect anything.
Does Disallow in robots.txt stop pages from appearing in Google?
Not reliably. The directive stops fetching, but Google may still list a blocked address it discovered through links; to keep a page out of results, owners place a noindex tag or header on a page crawlers are permitted to open.
Do I have to follow Crawl-delay?
The line is outside the official specification and Google pays no attention to it, but it tells you what pace the owner finds acceptable. Respecting it lowers server load and your own risk of being blocked at almost no cost.
How do sites block AI crawlers?
Typically by adding a dedicated block with Disallow rules for each AI agent, for example GPTBot or ClaudeBot, and sometimes by publishing content signals or filtering such traffic at the network edge. Vendor documentation lists the current agent names.


