Like jq, but for HTML.
Like jq, but for HTML. Uses CSS selectors to extract bits of content from HTML files.
cargo install htmlqpkg install htmlqbrew install htmlqscoop install htmlq…$ curl --silent https://www.rust-lang.org/ | htmlq '#get-help'
</div>$ curl --silent https://www.rust-lang.org/ | htmlq --attribute href a
/
/tools/install
/learn
/tools
/governance
/community
https://blog.rust-lang.org/
/learn/get-started
https://blog.rust-lang.org/2019/04/25/Rust-1.34.1.html
https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
[...]…There's a big SVG image in this page that I don't need, so here's how to remove it.
…(This is a bit of a work in progress)
$ curl --silent https://mgdm.net | htmlq --pretty '#posts'
<section id="posts">
<h2>I write about...
</h2>
<ul class="post-list">
<li>
<time datetime="2019-04-29 00:%i:1556496000" pubdate="">
29/04/2019</time><a href="/weblog/nettop/">
<h3>Debugging network connections on macOS with nettop
</h3></a>
<p>Using nettop to find out what network connections a program is trying to make.
</p>
</li>
[...]bat$ curl --silent example.com | htmlq 'body' | bat --language htmlPanic with :has selector
htmlq 0.4.0: code: 32, kind: BrokenPipe, message: "Broken pipe"
panic on ampersand
Error when a selector ID includes a space
Panic with `a` selector
Option to select the inner contents of a tag
Tranform <br> to \n when using --text flag
Bug: outputs "corrected" HTML, even if input was sloppy
nixos website example does not work anymore
Update HTML Nodes / Attributes