css - search HTML documents by CSS selectors
css [-c0h] [-m num] pattern [file...]
Foo.
Count hits, rather than enumerating them.
Use a NUL
terminator for interoperability with other programs.
Limit search to num hits.
Success.
Indicates a usage problem, such as passing an invalid flag or using a malformed selector.
An internal program error occurred whilst grepping the document.
An I/O error caused by failure to read or write to disk.
Given the followig HTML document, blog.html:
<!doctype html>
<meta charset=utf-8>
<title>My first blog post</title>
<meta name=keywords content=blog,first,hello>
<meta name=description content="First entry to blog.">
To find all occurrences of <meta
> elements:
% css meta blog.html
<meta content="blog,first,hello" name="keywords">
<meta content="First entry to blog." name="description">
And to only look for <meta
> elements with a name attribute equal to "keywords" and a content attribute containing "blog" in a space-separated list:
% css meta[name=keywords][content~=blog] blog.html
<meta content="blog,first,hello" name="keywords">
It can also receive streaming content from stdin:
% curl -L https://sny.no/ | css title
<title>Andreas Tolfsen</title>