Robots.txt und Ethik beim Scraping
Verstehen Sie die rechtlichen und ethischen Grundlagen des Web-Scrapings: robots.txt, Nutzungsbedingungen, Rate Limiting und verantwortungsvolles Verhalten.
Robots.txt und Ethik beim Scraping ist eine kostenlose Web Scraping & Bots-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Web Scraping & Bots-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Web Scraping & Bots-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Scraping Responsibly
Scraping touches other people’s servers and data. Before your first scraper, learn the rules and ethics that keep you safe and respectful.
What Is robots.txt?
robots.txt lives at a site’s root and tells automated clients which paths they may or may not access.
# https://example.com/robots.txt
User-agent: *
Disallow: /admin/
Allow: /public/Reading the Directives
Read the directives: User-agent targets a crawler, Disallow blocks paths, Allow adds exceptions, Crawl-delay sets a wait.
Checking robots.txt in Python
Python’s built-in urllib.robotparser reads and evaluates robots.txt for you — just ask it whether you can fetch a URL.
from urllib.robotparser import RobotFileParser
rp = RobotFileParser()
rp.set_url('https://example.com/robots.txt')
rp.read()
print(rp.can_fetch('*', 'https://example.com/public/page'))robots.txt Is Not Law
Remember: robots.txt is a request, not a lock. Ignoring it isn’t a crime by itself, but it can breach terms of service. Respect it anyway.
Terms of Service
A site’s Terms of Service may flat-out forbid automated access. Breaking them can mean account bans or legal trouble — always check first.
Personal & Copyrighted Data
Tread carefully with personal data (privacy laws like GDPR) and copyrighted content. Collecting or republishing them can carry real consequences.
Rate Limiting
Rapid-fire requests can overload a server — and get you blocked. Add a delay between requests to stay polite.
import time
for url in urls:
fetch(url)
time.sleep(2) # be politeIdentify Yourself
Set an honest User-Agent header, ideally with contact info, so site owners can reach you instead of just blocking you.
headers = {
'User-Agent': 'MyResearchBot/1.0 (contact@example.com)'
}Prefer Official APIs
If a site offers an API, use it. APIs are stable, sanctioned, and far gentler than scraping raw HTML.
Cache to Reduce Load
Cache responses locally so you don’t re-fetch the same page over and over while developing.
import os
if not os.path.exists('page.html'):
save(fetch(url), 'page.html')
html = open('page.html').read()Quick Check
What is the correct way to think about robots.txt?
Recap
You’ve got scraping ethics: respecting robots.txt, terms, privacy and copyright, rate limiting, honest User-Agents, and preferring APIs and caching.
Häufig gestellte Fragen
Ist die Lektion „Robots.txt und Ethik beim Scraping“ kostenlos?
Ja — der vollständige Text von „Robots.txt und Ethik beim Scraping“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Web Scraping & Bots-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Web Scraping & Bots-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Robots.txt und Ethik beim Scraping“?
Verstehen Sie die rechtlichen und ethischen Grundlagen des Web-Scrapings: robots.txt, Nutzungsbedingungen, Rate Limiting und verantwortungsvolles Verhalten. Du übst Web Scraping & Bots mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Web Scraping & Bots zu starten?
Keine Vorkenntnisse erforderlich. Web Scraping & Bots auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Robots.txt und Ethik beim Scraping“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Web Scraping & Bots-Lektion Code schreiben und ausführen?
Ja. Jede Web Scraping & Bots-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Was ist Web Scraping?
- HTTP-Anfragen und -Antworten
- Webseiten untersuchen
- Robots.txt und Ethik beim Scraping