HTMLQ
stumpled upon some thing cool, htmlq! It’s like jq, but for HTML.
Installation Rust
htmlq need rust. so, let’s install rust first.
doas pkg_add rust
Add Link to Path
cat << 'EOF' |doas tee -a /etc/profile
# Rust/Cargo
export PATH=$PATH:/root/.cargo/bin
EOF
. /etc/profile
Install HTMLQ
doas cargo install htmlq
some Examples
Extract Links
curl -s https://www.openbsd.org | htmlq --attribute href a |head
Example
user@nixbox$ curl -s https://www.openbsd.org | htmlq --attribute href a |head
goals.html
plat.html
security.html
crypto.html
events.html
innovations.html
faq/faq4.html#Download
anoncvs.html
https://cvsweb.openbsd.org/
https://github.com/openbsd
Extract complete links URL
curl --silent https://www.nytimes.com | htmlq a --attribute href -b https://www.nytimes.com
Example