https://github.com/pombadev/node2text
Parse HTML in your terminal
https://github.com/pombadev/node2text
cli command-line command-line-tool commandline css-selector-parser css-selectors html rust rust-crate rust-lang
Last synced: 4 months ago
JSON representation
Parse HTML in your terminal
- Host: GitHub
- URL: https://github.com/pombadev/node2text
- Owner: pombadev
- License: mit
- Created: 2021-06-18T14:30:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-10T04:44:57.000Z (over 4 years ago)
- Last Synced: 2025-01-06T10:04:23.320Z (about 1 year ago)
- Topics: cli, command-line, command-line-tool, commandline, css-selector-parser, css-selectors, html, rust, rust-crate, rust-lang
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT.md
Awesome Lists containing this project
README
# node2text [](https://crates.io/crates/node2text) 
> A tool to extract text from HTML from your terminal.
# Usage
```bash
# pipe in
curl -s 'https://en.wikipedia.org/wiki/Wiki' | node2text '#siteSub'
# Outputs: From Wikipedia, the free encyclopedia
# extract from path
node2text '#app.title' /path/to/file.html
# May or may not output depending on if selector is matched
```
# Motivation
When I reinstall my machine, I want to automate my install process. Usually it involves quickly grabbing snippet from the internet and writing it to file, this tool aims to help script it.
Hugely inspired by [pup](https://github.com/ericchiang/pup).
# Demo
[](./assets/demo.svg)
# Installation
If you have rust toolchain installed, `node2text` is available on [crates.io](https://crates.io/crates/node2text), if you don't have rust toolchain installed, please install rust by going to the [official website](https://www.rust-lang.org/tools/install).
Run
```bash
cargo install node2text
```
# Note
Piping will always take precedence even if `` is provided.
# Comparison with [pup](https://github.com/ericchiang/pup):
`node2text`
- Selectors are purely CSS selectors, no dsl
- Takes html, spits out text
- Written in rust programming language
- Less features than `pup`
- Outputs are not escaped
`pup`
- Selectors are CSS selectors plus dsl
- Takes html, spits out text, json, html
- Written in go programming language
- Has many features, visit their github page to know more
- Outputs are escaped