1
Fork 0
select-html/README.md

70 lines
1.9 KiB
Markdown
Raw Normal View History

# Select 👁️ HTML
2022-09-05 12:24:49 +00:00
> **Extract HTML using CSS selectors in the command-line.**
2022-09-05 12:24:49 +00:00
## Features
* Input HTML using stdin or a file.
* Output full elements, inner text or attribute values.
* Trim excess whitespace from output.
## Installation
### Cargo
With a working [Rust and Cargo](https://www.rust-lang.org/learn/get-started) installation, you can install `select-html` from [Crates.io](https://crates.io/crates/select-html).
```
cargo install select-html
```
### Binaries
Precompiled `x86_64-unknown-linux-gnu` binaries are available on the [Releases page](https://git.bauke.xyz/Bauke/select-html/releases).
## Examples
2022-09-05 12:24:49 +00:00
```sh
# Use stdin to pipe HTML to select-html.
curl -s https://example.org | select-html
# Or use `--file`.
select-html --file 'example.html'
# Select and output HTML.
select-html 'title'
# Output only the inner text of selected elements.
select-html '.example' --text
# Output attribute values.
select-html '[property^="og:"]' -a 'property' -a 'content'
```
## Usage
2022-09-05 12:24:49 +00:00
```
USAGE:
select-html [OPTIONS] <SELECTOR>
ARGS:
<SELECTOR> The CSS selector to use
OPTIONS:
-a, --attribute <ATTRIBUTE> Output the attribute's value from the selected element, can be
used multiple times
--file <FILE> A HTML file to read, if not specified stdin will be used instead
-h, --help Print help information
-t, --text Output inner text of the selected elements
--trim Trim whitespace from selected items
-V, --version Print version information
```
## Feedback
Found a problem or want to request a new feature? Email [me@bauke.xyz](mailto:me@bauke.xyz) and I'll see what I can do for you.
## License
Distributed under the [AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later.html) license, see [LICENSE](https://git.bauke.xyz/Bauke/select-html/src/branch/main/LICENSE) for more information.