MCPcopy Index your code
hub / github.com/Folyd/robotstxt

github.com/Folyd/robotstxt @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
82 symbols 147 edges 8 files 28 documented · 34%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

robotstxt

Crates.io Docs.rs Apache 2.0

A native Rust port of Google's robots.txt parser and matcher C++ library.

  • Native Rust port, no third-part crate dependency
  • Preserves all behavior of original library
  • Consistent API with original library
  • 100% google original test passed

Installation

[dependencies]
robotstxt = "0.2.0"

Quick start

use robotstxt::DefaultMatcher;

let mut matcher = DefaultMatcher::default();
let robots_body = "user-agent: FooBot\n\
                   disallow: /\n";
assert_eq!(false, matcher.one_agent_allowed_by_robots(robots_body, "FooBot", "https://foo.com/"));

About

Quoting the README from Google's robots.txt parser and matcher repo:

The Robots Exclusion Protocol (REP) is a standard that enables website owners to control which URLs may be accessed by automated clients (i.e. crawlers) through a simple text file with a specific syntax. It's one of the basic building blocks of the internet as we know it and what allows search engines to operate.

Because the REP was only a de-facto standard for the past 25 years, different implementers implement parsing of robots.txt slightly differently, leading to confusion. This project aims to fix that by releasing the parser that Google uses.

The library is slightly modified (i.e. some internal headers and equivalent symbols) production code used by Googlebot, Google's crawler, to determine which URLs it may access based on rules provided by webmasters in robots.txt files. The library is released open-source to help developers build tools that better reflect Google's robots.txt parsing and matching.

Crate robotstxt aims to be a faithful conversion, from C++ to Rust, of Google's robots.txt parser and matcher.

Testing

$ git clone https://github.com/Folyd/robotstxt
Cloning into 'robotstxt'...
$ cd robotstxt/tests 
...
$ mkdir c-build && cd c-build
...
$ cmake
...
$ make
...
$ make test
Running tests...
Test project ~/robotstxt/tests/c-build
    Start 1: robots-test
1/1 Test #1: robots-test ......................   Passed    0.33 sec

License

The robots.txt parser and matcher Rust library is licensed under the terms of the Apache license. See LICENSE for more information.

Extension points exported contracts — how you extend this code

RobotsParseHandler (Interface)
Handler for directives found in robots.txt. [3 implementers]
src/lib.rs
RobotsMatchStrategy (Interface)
Create a RobotsMatcher with the default matching strategy. The default matching strategy is longest-match as opposed to [1 …
src/matcher.rs

Core symbols most depended-on inside this repo

priority
called by 18
src/matcher.rs
parse_robotstxt
called by 12
src/lib.rs
set
called by 5
src/matcher.rs
validate_key
called by 4
src/parser.rs
digest
called by 4
src/lib.rs
clear
called by 3
src/matcher.rs
show_help
called by 2
src/main.rs
parse
called by 2
src/parser.rs

Shape

Method 51
Function 20
Class 8
Interface 2
Enum 1

Languages

Rust95%
C++5%

Modules by API surface

src/matcher.rs32 symbols
src/parser.rs24 symbols
src/lib.rs18 symbols
tests/src/robots_test.cc3 symbols
tests/src/lib.rs2 symbols
src/main.rs2 symbols
tests/src/simple_test.cpp1 symbols

For agents

$ claude mcp add robotstxt \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact