With jq one can query data in JSON files from the command line, what is useful for example when writing bash scripts, which just need one entry from a JSON file, like this

jq '.[0] | {message: .commit.message, name: .commit.committer.name}'

(Example taken from the tutorial)

I wonder if there are similar tools for HTML, which may for example accept an XPath or CSS selector as query and return the matching element(s).

  • github.com/ericchiang/pup Oct 15, 2021 at 16:32
  • 2
    github.com/mgdm/htmlq Oct 15, 2021 at 16:36
  • @glennjackman maybe this was just too easy. It is not packaged by my distribution (yet), but probably not too hard to compile. Do you like to make it an answer?
    – allo
    Oct 16, 2021 at 10:33
  • No need. You could write your own answer letting us know what solution you chose, and your reasons for doing so. Oct 16, 2021 at 12:53

1 Answer 1


I found this one https://github.com/mgdm/htmlq. There are some examples on the github page. e,i you can do something like this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.