Crates.io | crabquery |
lib.rs | crabquery |
version | 0.1.9 |
source | src |
created_at | 2020-02-21 03:04:21.693748 |
updated_at | 2022-04-01 19:00:14.568193 |
description | JQuery like HTML query library |
homepage | https://github.com/Gonzih/crabquery |
repository | https://github.com/Gonzih/crabquery |
max_upload_size | |
id | 211090 |
size | 42,128 |
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.
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");