Pup is a command-line utility fox extracting, filtering, and printing parts of HTML documents. It was inspired by the popular jq utility that can perform similar tasks for JSON documents, which was previously covered in the April 27, 2018, Scout Report. Users select parts of pages using CSS selector syntax. Pup includes support for complex syntax like attribute selectors, pseudo classes, and selector chaining. The full list of implemented selectors can be located in the PUP readme. In addition to just outputting the selected HTML, pup can also display the element text, element attributes, or a JSON serialization of the HTML information. The pup readme contains a quick start that demonstrates how to generate a JSON format list of articles currently on the front page of Hacker News. Pup executables can be downloaded from the releases page for a variety of systems including Windows, macOS, Linux, and several BSDs. Pup is free software, distributed under the MIT license, with source code available on GitHub.
Comments