1
Fork 0
Extract HTML using CSS selectors in the command-line. https://crates.io/crates/select-html
Go to file
Bauke f419552c96
Version 0.1.2!
2024-01-25 19:14:06 +01:00
source Update dependencies. 2024-01-25 18:52:13 +01:00
tests Initial commit! 🚀 2022-09-05 14:24:49 +02:00
.envrc Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
.gitignore Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
Cargo.lock Version 0.1.2! 2024-01-25 19:14:06 +01:00
Cargo.toml Version 0.1.2! 2024-01-25 19:14:06 +01:00
LICENSE Initial commit! 🚀 2022-09-05 14:24:49 +02:00
Makefile.toml Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
README.md Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
flake.lock Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
flake.nix Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
rustfmt.toml Initial commit! 🚀 2022-09-05 14:24:49 +02:00
rustup-toolchain.toml Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
shell.nix Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00

README.md

Select 👁 HTML

Extract HTML using CSS selectors in the command-line.

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 installation, you can install select-html from Crates.io.

cargo install select-html

Binaries

Precompiled x86_64-unknown-linux-gnu binaries are available on the Releases page.

Examples

# 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

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

Development

With Nix flakes and direnv installed and enabled, all the required dependencies are automatically loaded from shell.nix. Then cargo-make can be used to build, deploy and lint the code. The available tasks are all described in the Makefile.toml configuration.

Feedback

Found a problem or want to request a new feature? Email me@bauke.xyz and I'll see what I can do for you.

License

Distributed under the AGPL-3.0-or-later license, see LICENSE for more information.