Crates.io | html_query_parser |
lib.rs | html_query_parser |
version | 0.3.1 |
source | src |
created_at | 2021-12-23 03:25:58.568586 |
updated_at | 2022-01-01 13:27:13.36067 |
description | Pure, simple and elegant HTML parser and query selector. |
homepage | https://github.com/lomirus/html_query_parser |
repository | https://github.com/lomirus/html_query_parser |
max_upload_size | |
id | 502031 |
size | 39,996 |
This repository has been deprecated, please use the html-editor instead.
If you want to have the ownership of this crate name, please contact me at lomirus@qq.com so I can transfer it to you.
Pure, simple and elegant HTML parser and query selector.
let document = parse("<!doctype html><html><head></head><body></body></html>");
println!("{:#?}", document);
Output:
[
Doctype,
Element {
name: "html",
attrs: {},
children: [
Element {
name: "head",
attrs: {},
children: [],
},
Element {
name: "body",
attrs: {},
children: [],
},
],
},
]
// let html = r#"..."#
let nodes = parse(html);
let selector: Selector = Selector::from(".last");
let element: Element = nodes.query(&selector).unwrap();
// let html = r#"..."#
let nodes = parse(html);
let selector: Selector = Selector::from("span");
let elements: Vec<Element> = nodes.query_all(&selector);
// let html = r#"..."#
let a: String = parse(html).trim().html();
let b: String = parse(html).insert_to(&selector, node).html();
let c: String = parse(html).remove_by(&selector).html();
You can find more examples in the documentation.
See in CHANGELOG.md