bevacqua/hget
关于
👏 在终端中将网站渲染为纯文本。
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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 <html>. You can choose to take raw Markdown output as well, instead of the default terminal-formatted plain text.
Install
Globally or locally.
npm install hget --save
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.
var hget = require('hget');
var html = '<p>Hello <b>Nico</b>!</p>';
hget(html);
// <- 'Hello Nico!'
You can also pass in a few options.
hget(html, options)
The options are as follows.
rootsets the context root, it defaults to'body'. Maybe you want to use'main'or something akin to that.ignorecan 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 therootelement.htmlmeans that you'll get HTML back, instead of the default human-readable terminal outputmarkdownmeans you'll get Markdown back, instead of the default human-readable terminal output
CLI
Easy and flexible to use!
hget ponyfoo.com
hget file.html
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.
hget echojs.com --root #newslist --ignore "article>:not(h2)"

License
MIT
探索相关项目
加载中…