Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bevacqua/hget
:clap: Render websites in plain text from your terminal
https://github.com/bevacqua/hget
Last synced: 18 days ago
JSON representation
:clap: Render websites in plain text from your terminal
- Host: GitHub
- URL: https://github.com/bevacqua/hget
- Owner: bevacqua
- Created: 2014-11-05T23:12:42.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-03-16T02:17:14.000Z (9 months ago)
- Last Synced: 2024-04-14T10:15:27.733Z (8 months ago)
- Language: HTML
- Homepage: https://ponyfoo.com
- Size: 25.4 KB
- Stars: 348
- Watchers: 7
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-cli-apps - hget - Render websites in plain text from your terminal. (Utilities / Browser Replacement)
- fucking-awesome-cli-apps - hget - Render websites in plain text from your terminal. (Utilities / Browser Replacement)
README
# hget
> **Render websites in plain text from your terminal**
A CLI and an API to convert HTML into plain text. Can be used to fetch a site's HTML version and convert it into plain text, or to deliver plain text versions of your site dynamically.
You can also convert HTML into HTML, ignoring certain document elements, and starting at a root element other than ``. You can choose to take raw Markdown output as well, instead of the default terminal-formatted plain text.
# Install
Globally or locally.
```shell
npm install hget --save
``````shell
npm install hget -g
```# API
The API exports a function that takes in HTML and returns a formatted plain text string. It uses colors and formatting provided by [`chalk`][1].
```js
var hget = require('hget');
var html = 'Hello Nico!
';hget(html);
// <- 'Hello Nico!'
```You can also pass in a few options.
## `hget(html, options)`
The options are as follows.
- `root` sets the context root, it defaults to `'body'`. Maybe you want to use `'main'` or something akin to that.
- `ignore` can be a single selector or an array of selectors. Any elements that match the provided selectors will be removed from the document before rendering the terminal-printable output. Keep in mind that these selectors will be rooted in the `root` element.
- `html` means that you'll get HTML back, instead of the default human-readable terminal output
- `markdown` means you'll get Markdown back, instead of the default human-readable terminal output# CLI
Easy and flexible to use!
```shell
hget ponyfoo.com
``````shell
hget file.html
``````shell
cat file.html | hget
```# Example usage
Ooh, the CLI also follows redirects.
```
hget ponyfoo.com/articles/last --root article --ignore footer,.mm-count,.at-meta
```Also, the output will be paged using `$PAGER` for convenience. You can turn this off using `--no-paging`.
It works well on most sites. Here's just the news links from EchoJS.
```shell
hget echojs.com --root #newslist --ignore "article>:not(h2)"
```![echojs-output.png][2]
# License
MIT
[1]: https://www.npmjs.org/package/chalk
[2]: http://i.imgur.com/SlwwrqL.png[npm-badge]: https://img.shields.io/npm/v/hget.svg
[npm-url]: https://npmjs.com/package/hget
[travis-badge]: https://api.travis-ci.org/bevacqua/hget.svg
[travis-url]: https://travis-ci.org/bevacqua/hget
[coverage-badge]: https://coveralls.io/repos/bevacqua/hget/badge.svg?branch=master&service=github
[coverage-url]: https://coveralls.io/github/bevacqua/hget?branch=master
[david-badge]: https://david-dm.org/bevacqua/hget.svg
[david-url]: https://david-dm.org/bevacqua/hget