Does robots.txt stop scraping?

Basic3 min readUpdated

GET /learn/scraping/does-robots-txt-stop-scraping/ Accept text/html text/markdown

Short answer

No. robots.txt is a voluntary standard (RFC 9309) that asks crawlers which paths to avoid. Search engines and most documented AI crawlers follow it, but scrapers after your data ignore it, and some AI fetchers acting for a user may not apply it. The file is public, so listing sensitive paths in it tells everyone where they are.

robots.txt is a plain text file at the root of a host that tells crawlers which paths they may fetch. RFC 9309, published by the IETF in 2022, standardised a format that crawlers had followed informally since the 1990s. The RFC states that these rules "are not a form of access authorization". A crawler reads the file and decides whether to obey it, and nothing on your server enforces the result.

How does robots.txt work?

  • The file lives at /robots.txt on each host, so www.example.com and shop.example.com need separate files.
  • Rules sit in groups under one or more User-agent lines. A crawler matches its product token case-insensitively, follows the group that names it, and falls back to the User-agent: * group only if no group names it.
  • Within a group, Allow and Disallow rules match URL paths by prefix. The longest matching rule wins, and Allow wins a tie.
  • * matches any sequence of characters and $ marks the end of the URL.
  • Crawlers may cache the file, but should not use a cached copy for more than 24 hours unless the file cannot be reached.
  • If robots.txt returns a 4xx status, crawlers may treat everything as allowed. If it returns a 5xx status, they must assume everything is disallowed.

Who follows robots.txt and who does not?

Search engines and other good bots follow it. So do most AI crawlers that publish documentation, including OpenAI's GPTBot, Anthropic's ClaudeBot and Amazon's Amazonbot.

Some AI fetchers that load a page because a person asked an assistant treat robots.txt differently. OpenAI says robots.txt rules "may not apply" to ChatGPT-User, and Perplexity says Perplexity-User "generally ignores robots.txt rules". What are AI crawlers? lists each operator's stated position.

Scrapers that want your prices or content have no reason to read the file, and many never request it. A scraper that does read it gets a list of the paths you care about.

Why robots.txt can make scraping easier

The file is public. Anyone can open /robots.txt on your site, and the RFC warns that "listing paths in the robots.txt file exposes them publicly and thus makes the paths discoverable". A line such as Disallow: /internal-reports/ tells every visitor that the directory exists. Put private content behind authentication and leave it out of robots.txt.

robots.txt also does not keep pages out of Google's index. Google can index a disallowed URL without its content when other pages link to it. To keep a page out of search results, allow crawling and add a noindex rule, as Google's documentation explains.

A correct robots.txt example

txt
User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /search
Allow: /search/help
Disallow: /*.pdf$

User-agent: GPTBot
User-agent: CCBot
Disallow: /

Sitemap: https://www.example.com/sitemap.xml

What each part does:

  • Disallow: /search is a prefix, so it also blocks /search?q=shoes and /searching.
  • Allow: /search/help is longer than /search, so it wins and the help page stays crawlable.
  • Disallow: /*.pdf$ blocks URLs that end in .pdf. Because $ anchors the end, /report.pdf?v=2 is not blocked.
  • The two User-agent lines share one group, so GPTBot and CCBot are both blocked from the whole site.
  • Sitemap is outside the core RFC 9309 rules, but the RFC allows extra records and the major search engines read this one.

The group mistake that opens your site

A crawler that finds a group naming it ignores the * group completely, so none of those rules carry over.

txt
User-agent: *
Disallow: /search
Disallow: /cart/

User-agent: GPTBot
Disallow: /reports/

Here GPTBot may crawl /search and /cart/, because its own group only mentions /reports/. Repeat every rule you want a named crawler to follow inside its own group. After a change, check the robots.txt report in Google Search Console, which shows the file Google fetched and any problems it found parsing it.

What stops scrapers instead?

robots.txt manages crawlers that choose to cooperate. For the rest you need controls on the server: rate limits, bot detection and a login in front of the data that matters most. How to prevent web scraping covers those layers, and how to block AI crawlers turns robots.txt rules for AI bots into server rules that return 403.

Common questions

Does robots.txt block AI crawlers?

It blocks the AI crawlers that choose to honour it, which includes the training crawlers of the large AI companies. It has no effect on scrapers that hide their identity, and some fetchers that act on a user's request may not apply it.

Is ignoring robots.txt illegal?

robots.txt is a voluntary convention, so ignoring it is rarely unlawful on its own. It can still count in a dispute as evidence of what the site owner permitted, and in the EU a machine-readable opt-out affects whether the text and data mining exception applies.

How long until robots.txt changes take effect?

Up to about a day for crawlers that follow RFC 9309, which tells them not to rely on a cached copy for more than 24 hours. OpenAI and Meta give a similar figure for their crawlers. Scrapers that never read the file are unaffected.