Trait ScraperResponse

Source
pub trait ScraperResponse {
    // Required methods
    fn jsonpath(self) -> impl Future<Output = Result<Json>>;
    fn json_with_path_to_err<T: DeserializeOwned>(
        self,
    ) -> impl Future<Output = Result<T>>;
    fn css_selector(self) -> impl Future<Output = Result<Html>>;
    fn xpath(self) -> impl Future<Output = Result<XHtml>>;
    fn html(self) -> impl Future<Output = Result<String>>;
}
Expand description

Support extended traits of jsonpath, css selector, and xpath

Required Methods§

Source

fn jsonpath(self) -> impl Future<Output = Result<Json>>

Use jsonpath to select the response body

Source

fn json_with_path_to_err<T: DeserializeOwned>( self, ) -> impl Future<Output = Result<T>>

works with any existing Serde Deserializer and exposes the chain of field names leading to the error.

  • https://crates.io/crates/serde_path_to_error
Source

fn css_selector(self) -> impl Future<Output = Result<Html>>

Use CSS selector to select the response body

Source

fn xpath(self) -> impl Future<Output = Result<XHtml>>

Use XPath to select the response body

Source

fn html(self) -> impl Future<Output = Result<String>>

If there is no Encoding method in the Content-Type of the response header, try to read the meta information in the HTML to obtain the encoding. eg:

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§