news.volyx.in

Htmlq: like jq, but for html (github.com)

961 points by jabo · 1842 days ago · 166 comments on HN

Article summary

Htmlq is a tool that allows users to extract data from HTML files using CSS selectors, similar to how jq is used for JSON data. It can be installed using various package managers and has several options for customizing its output. Htmlq can be used for tasks such as extracting links, text content, and removing nodes from HTML files. The tool is designed to be a general-purpose solution for parsing HTML files from the command line.

Main themes

  • htmlq tool
  • CSS selectors
  • HTML parsing
  • command-line tools
  • jq comparison
  • existing alternatives
  • parser implementation
  • regular expressions
  • DOM-like tree parsing
  • tool limitations
  • use cases and applications
  • simplicity and ease of use
  • feature comparisons
  • parser technologies
  • HTML complexity
  • tool design and philosophy
  • user needs and preferences

What commenters say

  • Some commenters find htmlq to be a useful tool for parsing HTML files, filling a gap in the command-line toolbox.
  • Others note that similar tools, such as pup and xidel, already exist and offer comparable functionality.
  • There is disagreement over whether htmlq is truly analogous to jq, with some arguing that it is more akin to grep for HTML.
  • A few commenters suggest that incorporating an HTML parser into jq itself could be a useful extension of the tool's capabilities.
  • Some users appreciate the simplicity and ease of use of htmlq, particularly compared to other programming languages like Python with bs4.
  • Others argue that htmlq is limited in its functionality, lacking the full range of features offered by jq for JSON data.
  • The use of regular expressions for parsing HTML is discussed, with some arguing that it is not a suitable approach due to the complexity of HTML.
  • A few commenters note that htmlq uses a DOM-like tree for parsing HTML, rather than a full browser or regular expressions.