crabquery

Crates.iocrabquery
lib.rscrabquery
version0.1.9
sourcesrc
created_at2020-02-21 03:04:21.693748
updated_at2022-04-01 19:00:14.568193
descriptionJQuery like HTML query library
homepagehttps://github.com/Gonzih/crabquery
repositoryhttps://github.com/Gonzih/crabquery
max_upload_size
id211090
size42,128
Max Gonzih (Gonzih)

documentation

https://docs.rs/crabquery

README

CrabQuery - like JQuery, but for Crabs

CI Crates.io docs.rs MIT licensed

Small and simple library to query HTML markup for your web scraping needs.

Based on servo libraries. Supports more complicated CSS selectors than other similar libraries.

Examples

use crabquery::Document;

let doc = Document::from(
    "<div class='container'>
       <a class='link button' id='linkmain'>
         <span>text hi there</span>
       </a>
     </div>",
);

let sel = doc.select("div.container > a.button.link[id=\"linkmain\"]");
let el = sel.first().unwrap();

assert_eq!(el.attr("id").unwrap(), "linkmain");

let sel = doc.select("div > a > span");
let el = sel.first().unwrap();

assert_eq!(el.text().unwrap(), "text hi there");
Commit count: 54

cargo fmt