Expand description

Goal of this library is to help crabs with web crawling.

extern crate crabler;

use crabler::*;

#[derive(WebScraper)]
#[on_response(response_handler)]
#[on_html("a[href]", print_handler)]
struct Scraper {}

impl Scraper {
    async fn response_handler(&self, response: Response) -> Result<()> {
        println!("Status {}", response.status);
        Ok(())
    }

    async fn print_handler(&self, response: Response, a: Element) -> Result<()> {
        if let Some(href) = a.attr("href") {
            println!("Found link {} on {}", href, response.url);
        }

        Ok(())
    }
}

#[async_std::main]
async fn main() -> Result<()> {
    let scraper = Scraper {};

    scraper.run(Opts::new().with_urls(vec!["https://www.rust-lang.org/"])).await
}

Structs

Enums

Traits

Type Definitions

Attribute Macros

Derive Macros

Macro to derive WebScraper trait on to a given struct. Supported options: