mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-02-25 21:52:44 +00:00
Update cheatsheets
This commit is contained in:
29
tldr/htmlq
Normal file
29
tldr/htmlq
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
syntax: markdown
|
||||
tags: [tldr, common]
|
||||
source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# htmlq
|
||||
|
||||
> Use CSS selectors to extract content from HTML files.
|
||||
> More information: <https://github.com/mgdm/htmlq>.
|
||||
|
||||
- Return all elements of class `card`:
|
||||
|
||||
`cat {{path/to/file.html}} | htmlq '.card'`
|
||||
|
||||
- Get the text content of the first paragraph:
|
||||
|
||||
`cat {{path/to/file.html}} | htmlq --text 'p:first-of-type'`
|
||||
|
||||
- Find all the links in a page:
|
||||
|
||||
`cat {{path/to/file.html}} | htmlq --attribute href 'a'`
|
||||
|
||||
- Remove all images and SVGs from a page:
|
||||
|
||||
`cat {{path/to/file.html}} | htmlq --remove-nodes 'img' --remove-nodes 'svg'`
|
||||
|
||||
- Pretty print and write the output to a file:
|
||||
|
||||
`htmlq --pretty --filename {{path/to/input.html}} --output {{path/to/output.html}}`
|
||||
Reference in New Issue
Block a user