adieu
v1.0.0
Published
A command line interface to cheerio library; vaguely similar to nokogiri
Maintainers
Readme
A command line interface to cheerio library; vaguely similar to nokogiri; handy for shell scripts or makefiles.
$ npm -g i adieu$ adieu -h
Usage: adieu [options] [file.html | URL]
Options:
-e <code> JavaScript to run after HTML is parsed.
-p Automatically console.log results from -e.
-r <module> Preload a module.
-R Don't simplify cheerio objects printouts.
-V Output the version number.Print all image urls from google's front page:
$ adieu -pe '$("img").map((_,v)=>$(v).attr("src")).get().join`\n`' https://google.com
/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png
/textinputassistant/tia.pngRead html from the stdin:
$ curl -sL https://www.gnu.org | adieu -pe '$("h2").first().text()'
What is GNU?Load html into a repl:
$ adieu https://google.com
Your document should be available via $
> $('div').length
11
> $('div')[0]
Object [Element] {
type: 'tag',
name: 'div',
attribs: { id: 'mngb' },
'[inner_html]': '<div id="gbar"><nobr><b class="gb1">ПоD…',
parent: { type: 'tag', name: 'body' },
prev: { type: 'script', name: 'script' },
next: { type: 'tag', name: 'center' }
}Helpers
| name | desc |
| --------- | ----------------------------------------------------------- |
| cheerio | |
| $ | a cheerio instance w/ the loaded document |
| p | alias to console.log |
| puts | convert an arg to a string & write the result to the stdout |
License
MIT
