Struct robotparser_fork::RobotFileParser
source · [−]pub struct RobotFileParser<'a> {
pub user_agent: String,
/* private fields */
}
Expand description
robots.txt file parser
Fields
user_agent: String
Implementations
sourceimpl<'a> RobotFileParser<'a>
impl<'a> RobotFileParser<'a>
pub fn new<T: AsRef<str>>(url: T) -> RobotFileParser<'a>
sourcepub fn mtime(&self) -> i64
pub fn mtime(&self) -> i64
Returns the time the robots.txt file was last fetched.
This is useful for long-running web spiders that need to check for new robots.txt files periodically.
sourcepub fn read(&self, client: Option<Client>)
pub fn read(&self, client: Option<Client>)
Reads the robots.txt URL and feeds it to the parser.
sourcepub fn from_response(&self, response: &mut Response)
pub fn from_response(&self, response: &mut Response)
Reads the HTTP response and feeds it to the parser.
sourcepub fn parse<T: AsRef<str>>(&self, lines: &[T])
pub fn parse<T: AsRef<str>>(&self, lines: &[T])
Parse the input lines from a robots.txt file
We allow that a user-agent: line is not preceded by one or more blank lines.
sourcepub fn can_fetch<T: AsRef<str>>(&self, useragent: T, url: T) -> bool
pub fn can_fetch<T: AsRef<str>>(&self, useragent: T, url: T) -> bool
Using the parsed robots.txt decide if useragent can fetch url
sourcepub fn get_crawl_delay<T: AsRef<str>>(&self, useragent: T) -> Option<Duration>
pub fn get_crawl_delay<T: AsRef<str>>(&self, useragent: T) -> Option<Duration>
Returns the crawl delay for this user agent as a Duration
, or None if no crawl delay is defined.
sourcepub fn get_sitemaps<T: AsRef<str>>(&self, useragent: T) -> Vec<Url>
pub fn get_sitemaps<T: AsRef<str>>(&self, useragent: T) -> Vec<Url>
Returns the sitemaps for this user agent as a Vec<Url>
.
sourcepub fn get_req_rate<T: AsRef<str>>(&self, useragent: T) -> Option<RequestRate>
pub fn get_req_rate<T: AsRef<str>>(&self, useragent: T) -> Option<RequestRate>
Returns the request rate for this user agent as a RequestRate
, or None if not request rate is defined
Trait Implementations
sourceimpl<'a> Clone for RobotFileParser<'a>
impl<'a> Clone for RobotFileParser<'a>
sourcefn clone(&self) -> RobotFileParser<'a>
fn clone(&self) -> RobotFileParser<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for RobotFileParser<'a>
impl<'a> Debug for RobotFileParser<'a>
sourceimpl<'a> PartialEq<RobotFileParser<'a>> for RobotFileParser<'a>
impl<'a> PartialEq<RobotFileParser<'a>> for RobotFileParser<'a>
sourcefn eq(&self, other: &RobotFileParser<'a>) -> bool
fn eq(&self, other: &RobotFileParser<'a>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &RobotFileParser<'a>) -> bool
fn ne(&self, other: &RobotFileParser<'a>) -> bool
This method tests for !=
.
impl<'a> Eq for RobotFileParser<'a>
impl<'a> StructuralEq for RobotFileParser<'a>
impl<'a> StructuralPartialEq for RobotFileParser<'a>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for RobotFileParser<'a>
impl<'a> Send for RobotFileParser<'a>
impl<'a> !Sync for RobotFileParser<'a>
impl<'a> Unpin for RobotFileParser<'a>
impl<'a> UnwindSafe for RobotFileParser<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more