pub struct RobotFileParser { /* private fields */ }Expand description
Reads, parses and answers questions about a single robots.txt file. Port of RobotFileParser.
Implementations§
Source§impl RobotFileParser
impl RobotFileParser
Sourcepub fn new(url: &str) -> Self
pub fn new(url: &str) -> Self
Create a parser for the robots.txt at url (pass "" for none). Port of __init__.
Sourcepub fn mtime(&self) -> bool
pub fn mtime(&self) -> bool
Whether the file has been parsed yet. Port of mtime (truthiness only — no real clock).
Sourcepub fn set_url(&mut self, url: &str)
pub fn set_url(&mut self, url: &str)
Set the robots.txt URL, caching its host and path. Port of set_url. A malformed authority
leaves host/path empty rather than propagating (CPython would raise here).
Sourcepub fn parse<S: AsRef<str>>(&mut self, lines: &[S])
pub fn parse<S: AsRef<str>>(&mut self, lines: &[S])
Parse the lines of a robots.txt file (already split into lines, no trailing newlines). Port
of parse.
Sourcepub fn can_fetch(&self, useragent: &str, url: &str) -> Result<bool, UrlError>
pub fn can_fetch(&self, useragent: &str, url: &str) -> Result<bool, UrlError>
Decide whether useragent may fetch url, per the parsed robots.txt. Port of can_fetch.
Returns Err only when the URL’s authority is malformed (CPython raises ValueError from
the internal urlsplit).
Sourcepub fn crawl_delay(&self, useragent: &str) -> Option<i64>
pub fn crawl_delay(&self, useragent: &str) -> Option<i64>
The Crawl-delay for useragent, or None. Port of crawl_delay.
Sourcepub fn request_rate(&self, useragent: &str) -> Option<RequestRate>
pub fn request_rate(&self, useragent: &str) -> Option<RequestRate>
The Request-rate for useragent, or None. Port of request_rate.