Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

htmlq

> 编程语言
Open source

Like jq, but for HTML.

7.6K stars0 likes2 views
WebsiteGitHub

About

Like jq, but for HTML.

htmlq

Like jq, but for HTML. Uses CSS selectors to extract bits of content from HTML files.

Installation

Cargo

bash
cargo install htmlq

FreeBSD pkg

bash
pkg install htmlq

Homebrew

bash
brew install htmlq

Scoop

bash
scoop install htmlq

Usage

…

Examples

Using with cURL to find part of a page by ID

bash
$ curl --silent https://www.rust-lang.org/ | htmlq '#get-help'

      </div>

Find all the links in a page

bash
$ 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
[...]

Get the text content of a post

…

Remove a node before output

There's a big SVG image in this page that I don't need, so here's how to remove it.

…

Pretty print HTML

(This is a bit of a work in progress)

bash
$ 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>
[...]

Syntax highlighting with bat

bash
$ curl --silent example.com | htmlq 'body' | bat --language html

Issues· 43 open

View all issuesOpen on GitHub
  • #65

    Panic with :has selector

    Updated Sep 17, 2026
  • #73

    htmlq 0.4.0: code: 32, kind: BrokenPipe, message: "Broken pipe"

    Updated Feb 13, 2025
  • #78

    panic on ampersand

    Updated Jan 7, 2025
  • #51

    Error when a selector ID includes a space

    Updated Aug 21, 2024
  • #76

    Panic with `a` selector

    Updated Jul 31, 2024
  • #75

    Option to select the inner contents of a tag

    Updated Jul 1, 2024
  • #74

    Tranform <br> to \n when using --text flag

    Updated Jun 24, 2024
  • #53

    Bug: outputs "corrected" HTML, even if input was sloppy

    Updated May 30, 2024
  • #71

    nixos website example does not work anymore

    Updated Mar 27, 2024
  • #54

    Update HTML Nodes / Attributes

    Updated Dec 20, 2023

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言