robotspy is a Python library for parsing `robots.txt` files, implementing the Robots Exclusion Protocol (REP) as defined by RFC 9309. It allows applications to determine whether a web crawler is permitted to access a given URL path on a server. The library is actively maintained, with the current version being 0.13.0, and has a steady release cadence addressing bug fixes and adherence to Google's parsing behavior.
pip install robotspyVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize `RobotFileParser` with a URL, fetch the `robots.txt` file using `read()`, and then check crawling permissions for various user agents and paths using `can_fetch()`. It also shows how to set a custom `user_agent` when initializing the parser, which is used for fetching the `robots.txt` file itself.
Upgrade to `robotspy >= 0.10.0` to ensure correct and standard handling of the '?' character in `robots.txt` disallow/allow rules.
Upgrade to `robotspy >= 0.9.0` for more accurate parsing of `User-agent` lines, especially those with non-standard or partially malformed tokens.
Upgrade to `robotspy >= 0.8.0` to ensure better compatibility with `robots.txt` files using various character encodings.
If you encounter 403 errors, ensure you are using `robotspy >= 0.8.0`. For persistent issues, explicitly set a descriptive user agent when initializing the parser, e.g., `RobotFileParser(url=..., user_agent='MyCoolCrawler/1.0')`.
No dependency data recorded yet.