https://github.com/fefit/visdom
A library use jQuery like API for html parsing & node selecting & node mutation, suitable for web scraping and html confusion.
https://github.com/fefit/visdom
confuse css-selector dom-manipulation html-parse jquery rust scrape
Last synced: 16 days ago
JSON representation
A library use jQuery like API for html parsing & node selecting & node mutation, suitable for web scraping and html confusion.
- Host: GitHub
- URL: https://github.com/fefit/visdom
- Owner: fefit
- License: mit
- Created: 2021-01-08T04:22:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-10-29T03:13:40.000Z (2 months ago)
- Last Synced: 2025-12-02T15:21:54.750Z (about 1 month ago)
- Topics: confuse, css-selector, dom-manipulation, html-parse, jquery, rust, scrape
- Language: Rust
- Homepage:
- Size: 656 KB
- Stars: 113
- Watchers: 2
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Visdom
[](https://github.com/fefit/visdom/actions)
[](https://crates.io/crates/visdom)
[](https://github.com/fefit/visdom/tags)
[](https://codecov.io/gh/fefit/visdom)
[](https://crates.io/crates/visdom)
[](https://docs.rs/visdom/latest)
[](https://github.com/fefit/visdom/blob/main/LICENSE)
[API Document](https://github.com/fefit/visdom/wiki/API-Document)
[Performance](https://github.com/fefit/visdom/blob/main/performance/README.md)
[中文 API 文档](https://github.com/fefit/visdom/wiki/%E4%B8%AD%E6%96%87API%E6%96%87%E6%A1%A3)
[更新文档](https://github.com/fefit/visdom/blob/main/CHANGELOG.md)
:house: A html parsing & node selecting and mutation library written in Rust, using APIs similar to jQuery, left off the parts thoes only worked in the browsers(e.g. render and event related methods).
It's not only helpful for the working with html scraping, but also have useful APIs to mutate `text` nodes, so you can use it for mixing your html with dirty html fragement, and keep the web scrapers away. :sparkling_heart:
## Usage
```rust
use visdom::Vis;
use visdom::types::BoxDynError;
fn main() -> Result<(), BoxDynError>{
let html = r##"
- Hello,
- Vis
- Dom
"##;
// load html
let root = Vis::load(html)?;
let lis = root.find("#header li");
let lis_text = lis.text();
println!("{}", lis_text);
// will output "Hello,VisDom"
Ok(())
}
```
[Try it online](http://visdom.suchjs.com/#hello)
## Feature flags
After version v0.5.0, visdom add some feature flags to support conditional compilation for different usage.
| Feature | Description | API | Config |
| :---------- | :---------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------- |
| `destroy` | When you don't need remove or clear the elements, you can ignore this feature flag. | `.remove()` `.empty()` (IElementTrait) `remove_child()` `clone()` | `visdom = { version = xxx, features = ["destroy"]}` |
| `insertion` | When you don't need mutation the DOM, you can ignore this feature flag. | `append()` `append_to()` `prepend()` `prepend_to()` `insert_after()` `after()` `insert_before()` `before()` `replace_with()` | `visdom = { version = xxx, features = ["insertion"]}` |
| `text` | When you don't need mutation the TextNode, you can ignore this feature flag. | `.texts()` `.texts_by()` `texts_by_rec()` | `visdom = { version = xxx, features = ["text"]}` |
| `full` | When you need all the API above, you can open this feature flag. | - | `visdom = { version = xxx, features = ["full"]}` |
## Depedencies
- Html parser:[https://github.com/fefit/rphtml](https://github.com/fefit/rphtml)
- Html entity encoding and decoding:[https://github.com/fefit/htmlentity](https://github.com/fefit/htmlentity)
## Questions & Advices & Bugs?
Welcome to report [Issue](https://github.com/fefit/visdom/issues) to us if you have any question or bug or good advice.
## License
[MIT License](./LICENSE).