New Amazon API: We've just released a brand new way to scrape Amazon at scale Start Free Trial 🐝

A Web Scraper’s Guide to Robots.txt

02 January 2026 | 8 min read

Everything has rules, and the main rulebook for web scraping is the robots.txt file. Think of it as the foundation for how web crawlers and scrapers interact with websites. It guides you through the ethical intricacies of automated data extraction and specifies your responsibilities.

In this guide, I’ll walk you through everything you need to know about robots.txt. You'll learn about its purpose, syntax, and why compliance matters. I'll also explain how tools like ScrapingBee can help you stay on the right side of the web scraping game.

Whether you’re a beginner or looking to sharpen your scraping skills, this article will help you interpret and follow robots.txt for ethical, efficient scraping.

What is Robots.txt: Quick Answer

At its core, robots.txt is a simple text file hosted on a website that communicates crawling permissions to automated agents: bots, crawlers, and scrapers. It tells these bots which parts of the website they are allowed to access and which parts are off-limits.

When you hear “web scraping robots.txt,” think of it as the website’s polite way of saying, “Here’s where you can go, and here’s where you can’t.” It’s not a security measure per se, but a guideline that helps keep web scraping activities compliant and respectful.

Understanding the Purpose of Robots.txt in Web Scraping

The Robots Exclusion Protocol (REP) is the official name behind robots.txt. Think of it as a doorman standing at the entrance of a website, checking the credentials of every bot that wants to come in. This doorman’s job is to ensure bots don’t wander into restricted areas, like private directories or admin panels.

Here’s a simple example of a robots.txt file you might find at https://example.com/robots.txt:

User-agent: *
Disallow: /private/

This means all bots (User-agent: *) are not allowed to crawl anything under /private/. It’s a straightforward way for website owners to protect sensitive or irrelevant sections from automated access.

From my experience, respecting robots.txt is not just about playing by the rules; it’s about building a sustainable scraping practice. Ignoring these rules can lead to IP bans, legal issues, or worse, damage your reputation as a developer.

If you want to dig deeper into data extraction techniques that complement robots.txt compliance, check out ScrapingBee’s data extraction features.

How Robots.txt Works – Key Directives and Syntax

Robots.txt files use a few key directives to communicate with bots.

Let’s break down the most common ones you’ll encounter:

User-agent: *
Disallow: /admin/
Allow: /admin/help/
Crawl-delay: 10
Sitemap: https://example.com/sitemap.xml
  • User-agent: Specifies which bot the rules apply to. * means all bots.

  • Disallow: Tells bots which paths they must not crawl.

  • Allow: Overrides Disallow for specific paths, allowing access.

  • Crawl-delay: Suggests how many seconds a bot should wait between requests to reduce server load.

  • Sitemap: Points bots to the sitemap file, which helps them discover pages to crawl.

When you’re building a scraper, it’s essential to parse these directives correctly. For example, if you see Disallow: /admin/ but Allow: /admin/help/, your scraper should avoid /admin/ but can safely access /admin/help/.

In my early scraping days, I underestimated the importance of Crawl-delay. As it turns out, bombarding a server with rapid requests can get you blocked fast. Meanwhile, adding a respectful delay is a simple way to avoid trouble and keep your scraper running smoothly.

Example of a Robots.txt File

Here’s a real-world example with annotations:

# Example robots.txt
User-agent: Googlebot
Disallow: /temp/
Allow: /public/
Crawl-delay: 5
Sitemap: https://example.com/sitemap.xml
  • User-agent: Googlebot — This section applies only to Google’s crawler.

  • Disallow: /temp/ — Googlebot should not crawl the /temp/ directory.

  • Allow: /public/ — But it can crawl /public/.

  • Crawl-delay: 5 — Googlebot should wait 5 seconds between requests.

  • Sitemap: Points to the sitemap location for better indexing.

Here's what the google.com/robots.txt file looks like:

Robots.txt

If you want to see how this file looks live, you can retrieve it programmatically:

curl https://example.com/robots.txt

And here’s a quick JSON-style example of how a scraper might parse these rules:

{
  "Googlebot": {
    "disallow": ["/temp/"],
    "allow": ["/public/"],
    "crawl-delay": 5,
    "sitemap": "https://example.com/sitemap.xml"
  }
}

ScrapingBee’s API can automatically handle this parsing and respect these rules, so you don’t have to reinvent the wheel. For more on how AI-powered scraping respects robots.txt, check out their AI Web Scraping API.

Why Robots.txt Compliance Matters in Web Scraping

Respecting robots.txt isn’t just about etiquette; it’s a matter of legal, ethical, and technical importance.

From a legal perspective, ignoring robots.txt can land you in hot water. Cases like eBay vs Bidder's Edge and LinkedIn vs Proxycurl highlight how companies have taken legal action against scrapers who ignored site rules.

Even giants like AWS have faced scrutiny for bot-related issues, as reported in the AWS & Perplexity investigation. The HiQ Labs vs LinkedIn case further illustrates the complex legal landscape around scraping and data access.

Robots.txt

From a technical standpoint, scraping without respecting robots.txt can overload servers, leading to IP bans or throttling. I’ve seen scrapers get blocked within minutes because they ignored crawl delays or accessed disallowed paths. It’s like showing up to a party uninvited and causing a ruckus; no one wants that.

It’s important to note that robots.txt itself isn’t legally enforceable. It’s a voluntary standard, but ignoring it can trigger bans or lawsuits, especially under laws like the Computer Fraud and Abuse Act (CFAA) in the U.S.

That's why it's important to use a reliable tool, which not only encourages compliance but also implements technical configurations, such as delays, to ensure you scrape ethically. This is the design principle that is embedded in a solution like ScrapingBee.

How to Read a Robots.txt File Before Scraping

Now, let me show you a quick step-by-step guide to reading robots.txt before you start scraping:

  1. Locate the file: Visit https://domain.com/robots.txt in your browser or via code.

  2. Parse the file: Use Python libraries like robotparser or ScrapingBee’s API to interpret the rules.

  3. Interpret the rules: Look for User-agent, Disallow, and other directives to understand what’s allowed.

  4. Respect the rules: Adjust your scraper’s behavior accordingly.

Here’s a simple Python snippet to fetch robots.txt:

import requests

url = 'https://example.com/robots.txt'
response = requests.get(url)

if response.status_code == 200:
    print(response.text)
else:
    print("robots.txt not found")

If you prefer no-code solutions, our solution integrates with tools like n8n to automate this process.

Ethical Web Scraping Best Practices

Ethical scraping is about more than just obeying robots.txt. It’s about being a good web citizen. Here are some best practices I always follow:

  • Rate limiting: Don’t hammer the server. Respect Crawl-delay or add your own delays.

  • Identify yourself: Use clear user-agent strings so site owners know who you are.

  • Avoid disallowed paths: Don’t scrape what’s off-limits.

  • Cache results: Don’t repeatedly scrape the same data unnecessarily.

Here’s a quick Python example showing respectful pacing:

import time

urls = ['https://example.com/page1', 'https://example.com/page2']

for url in urls:
    scrape(url)  # Your scraping function here
    time.sleep(5)  # Respect crawl-delay

Our platform takes care of these details automatically, including IP rotation and JavaScript rendering, so you can focus on your data, not other issues.

Using ScrapingBee for Robots.txt-Compliant Data Collection

ScrapingBee’s API is a powerful ally for compliant scraping. It respects robots.txt rules when appropriately configured by default.

Here’s a sample API call that respects robots.txt compliance:

curl -X GET "https://app.scrapingbee.com/api/v1/?api_key=YOUR_KEY&url=https://example.com&render_js=false"

This call fetches the page while honoring the site’s robots.txt directives, so you stay compliant without extra effort.

Common Robots.txt Misunderstandings

Now that you know what the robots.txt file is and how to read it, let's clear up a few myths:

  • Myth: Robots.txt blocks are legally binding.
    Reality: They’re guidelines, not laws, but ignoring them can have consequences.

  • Myth: All bots must obey robots.txt.
    Reality: Some malicious bots ignore it, but ethical scrapers should always comply.

  • Myth: Disallow: / means content is hidden.
    Reality: It just means bots shouldn’t crawl that path; content might still be publicly accessible.

Understanding these nuances helps you build smarter, more respectful scrapers.

Ready to Scrape Responsibly with Automation?

If you’re ready to take your scraping to the next level, efficiently, ethically, and hassle-free, give ScrapingBee a try. It automates compliance with robots.txt, manages tricky JavaScript rendering, and handles IP rotation, so you can focus on what matters: your data.

Start your journey with ScrapingBee today: Try ScrapingBee.

Robots.txt and Web Scraping FAQs

What is the purpose of a robots.txt file in web scraping?

It tells bots which parts of a website they can or cannot crawl, helping ensure scraping is done responsibly.

Is it illegal to scrape websites that disallow bots in robots.txt?

Not necessarily illegal, but ignoring robots.txt can lead to bans or legal issues depending on jurisdiction and site policies.

How can developers check if a site allows scraping?

By visiting domain.com/robots.txt and interpreting the rules specified there.

What happens if a scraper ignores robots.txt rules?

It risks IP bans, legal action, and damage to reputation.

Do all websites have a robots.txt file?

No, but most public sites do. If absent, there are no explicit crawl restrictions.

How does ScrapingBee help ensure robots.txt compliance?

It automatically parses and respects robots.txt rules, manages request pacing, and handles IP rotation to keep scraping ethical and efficient.

image description
Kevin Sahin

Kevin worked in the web scraping industry for 10 years before co-founding ScrapingBee. He is also the author of the Java Web Scraping Handbook.