1
Fork 0
Extract HTML using CSS selectors in the command-line. https://crates.io/crates/select-html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Bauke 962a45a0f3
Remove eye from source code.
5 months ago
source Remove eye from source code. 5 months ago
tests Initial commit! 🚀 5 months ago
.gitignore Initial commit! 🚀 5 months ago
Cargo.lock Version 0.1.1! 5 months ago
Cargo.toml Version 0.1.1! 5 months ago
LICENSE Initial commit! 🚀 5 months ago
Makefile.toml Initial commit! 🚀 5 months ago
README.md Fix excess Unicode character. 5 months ago
rustfmt.toml Initial commit! 🚀 5 months ago

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

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.