web-scraper

Crates.ioweb-scraper
lib.rsweb-scraper
version0.1.0
sourcesrc
created_at2024-05-03 21:33:45.997758
updated_at2024-05-03 21:33:45.997758
descriptionA rust crate, that is used to get html from a website, and scrape the content in it
homepage
repositoryhttps://github.com/Imo-Br/web-scraper
max_upload_size
id1229238
size20,025
petabyte_ (petabyte-imo)

documentation

README

Web-Scraper

A rust crate, that is used to get html from a website, and scrape the content in it

Example

The following code is an example of how to use it, it gets the html in the rust lang website, then it looks for all the div tags, and gets the contents inside of it

use web_scraper::site::get_html;
use web_scraper::HtmlTag;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>> {
    let file = get_html("https://rust-lang.org").await.unwrap();
    // Define the tag you want to parse
    let tag = HtmlTag::DIV;
    // Parse the <div> tags and collect the results into a vector
    let new_vector = tag.parse_tags(&file);

    // Print the parsed <div> tags
    for li_tag in &new_vector {
        println!("{}", li_tag);
    }

    Ok(())
}
Commit count: 6

cargo fmt