Skip to content

Repository files navigation

headless-eval pipeline statusdependency status

CLI tool to evaluate a JS snippet in a webpage context with headless chrome

Install

$ npm i -g headless-eval

Usage

$ headless-eval -hUsage: headless-eval [options] <url> <js_snippet>CLI tool to evaluate a JS snippet in a webpage context with headless chromeOptions: -V, --version output the version number -j, --json output result as JSON -h, --help output usage information

Examples

$ headless-eval https://news.ycombinator.com '[...document.querySelectorAll("a.titlelink")].slice(0, 3).map(a => `${a.textContent} - ${a.href}`)'Apple News No Longer Supports RSS - https://mjtsai.com/blog/2019/12/26/apple-news-no-longer-supports-rss/Darpa head resigns, moving on to industry - https://www.defensenews.com/breaking-news/2019/12/17/darpa-head-resigns-moving-on-to-industry/Scientists Likely Found Way to Grow New Teeth for Patients - https://www.sciencetimes.com/articles/24252/20191111/scientists-likely-found-way-to-grow-new-teeth-for-patients.htm
$ headless-eval -j https://news.ycombinator.com '[...document.querySelectorAll("a.titlelink")].slice(0, 3).map(({ textContent: title, href }) => ({ title, href }))'[ { "title": "Apple News No Longer Supports RSS", "href": "https://mjtsai.com/blog/2019/12/26/apple-news-no-longer-supports-rss/" }, { "title": "Darpa head resigns, moving on to industry", "href": "https://www.defensenews.com/breaking-news/2019/12/17/darpa-head-resigns-moving-on-to-industry/" }, { "title": "Scientists Likely Found Way to Grow New Teeth for Patients", "href": "https://www.sciencetimes.com/articles/24252/20191111/scientists-likely-found-way-to-grow-new-teeth-for-patients.htm" }]

About

CLI tool to evaluate a JS snippet in a webpage context with headless chrome

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages