我把 Google 的 robotstxt 解析库 port 到 rust 了,并且用 FFI 的方式跑通了 C++的测试用例。感兴趣的朋友欢迎 star 🥳
地址:https://github.com/Folyd/robotstxt
robotstxt
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/"));