robots-parser 0.1.0

A robots.txt file parser for rust
Documentation
  • Coverage
  • 42.86%
    6 out of 14 items documented0 out of 8 items with examples
  • Size
  • Source code size: 85.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.41 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 1s Average build duration of successful builds.
  • all releases: 1m 1s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • teuron

A robots.txt parser and applicability checker for Rust

Build Status Crates.io

Usage

Add it to your Cargo.toml:

[dependencies]
robots-parser = "0.10"

Examples

Parse and check from URL

use robots::RobotsParser;
use url::Url;

fn main() {
    let parsed = RobotsParser::parse_url(Url::new("https://www.google.com/robots.txt"))?;
    assert!(parsed.can_fetch("*", "https://www.google.com/search/about"));
}

Parse and check from File

use robots::RobotsParser;

fn main() {
    let parsed = RobotsParser::parse_path("~/test-robots.txt"))?;
    assert!(parsed.can_fetch("*", "http://test.com/can_fetch"));
}

Parse and check from &str

use robots::RobotsParser;

fn main() {
    let parsed = RobotsParser::parse_path("Disallow: /test"))?;
    assert!(!parsed.can_fetch("*", "http://test.com/test"));
}

License

This work is released under Apache and MIT license. A copy of the licenses are provided in the LICENSE-APACHE and LICENSE-MIT files.