2017-06-07 09:54:00 +00:00
|
|
|
# pup
|
|
|
|
#
|
2020-10-20 22:26:55 +00:00
|
|
|
# Command line too for processing HTML
|
|
|
|
# Reading from stdin, pup prints to stdout, allowing the user to filter parts
|
|
|
|
# of the page using CSS selectors.
|
2017-06-07 09:54:00 +00:00
|
|
|
|
2020-10-20 22:26:55 +00:00
|
|
|
# Install pup. Requires `go`.
|
2017-06-07 09:54:00 +00:00
|
|
|
go install github.com/ericchiang/pup
|
|
|
|
|
2020-10-20 22:26:55 +00:00
|
|
|
# Indent and colorize HTML.
|
2017-06-07 09:54:00 +00:00
|
|
|
cat file.html | pup --color
|
|
|
|
|
2020-10-20 22:26:55 +00:00
|
|
|
# Filter by tag.
|
2017-06-07 09:54:00 +00:00
|
|
|
cat file.html | pup 'title'
|
|
|
|
|
2020-10-20 22:26:55 +00:00
|
|
|
# Pseudoclass: filter by content "History".
|
2017-06-07 09:54:00 +00:00
|
|
|
cat file.html | pup ':contains("History")'
|
|
|
|
|
2020-10-20 22:26:55 +00:00
|
|
|
# Multiple groups of selectors.
|
2017-06-07 09:54:00 +00:00
|
|
|
cat file.html | pup 'title, h1 span[dir="auto"]'
|