Affichage des articles dont le libellé est utility. Afficher tous les articles
Affichage des articles dont le libellé est utility. Afficher tous les articles

lundi 3 décembre 2012

html pager `onliner` with xmllint aka Y U NO RTFM

TIL xmllint can interpret XPath expressions, and has a html parser. No more ugly frankensed expressions to deals with trees. Ahhh DSLs.


dummy@x60s_GPT ~ % for page in $(hrefs URL | egrep $(basename URL) | sort | uniq) ;
do
curl -sL ${page}
| xmllint --html --xpath '//*[@id="content"]' -
| html2text;
done | less


where hrefs is, note the old school sedism which will soon be deprecated:

dummy@x60s_GPT ~ % cat $(which hrefs)

#!/usr/bin/env dash

URL="${1}"
curl -sL ${URL} | sed 's.>.>\n.g' | sed -n '/href/I s@^.*href="\([^"]\+\)".*$@\1@Igp' 


ps: no need to criticize my fault-tolerantless style; I'm still waiting for a whole lisp user-space so why bother...

lundi 26 mars 2012

introducing the filep utility

a UNIXy program that can retrieve a schema for most file types ( some files like mp3 can't have a schema, there's some dynamic tricks in the format IIRC ) and displays it as an API. Then you query it using xpath/css:selector syntax.

That would solve the parser library problem of new languages*, and improve education.

*: well .. it would still be string all the way down, which I despise. 'the hell with strings, it should output json/yaml, it's a decent newer common pivot for atomic types and collections.

ps: there's nothing else but this rant embryo here. Sorry for the phising name