From 2ee8173625ffe8683fb18384a96f7b44b5ddc8fb Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 6 Sep 2011 22:48:35 +0200 Subject: //util dict.leo.org: initial import --- util/bin/dict.leo.org | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 util/bin/dict.leo.org (limited to 'util/bin/dict.leo.org') diff --git a/util/bin/dict.leo.org b/util/bin/dict.leo.org new file mode 100755 index 00000000..6a9d9669 --- /dev/null +++ b/util/bin/dict.leo.org @@ -0,0 +1,87 @@ +#! /bin/sh +#### dict.leo.org version 2.0 beta 1 +set -euf + +cache_dir=/tmp/dict.leo.org/ +file="$cache_dir$*" + +url="http://dict.leo.org/?$*" + +# TODO check sanity of filename + +if test -d "$cache_dir" ; then + test -e "$file" || { curl --silent "$url" | tee "$file" ; } +else + curl --silent "$url" +fi | +sed 's/>\( *.\)/>\n\1/g' | sed -rn ' + s/[[:space:]]/ /g + //,/<\/td>/b + //,/^<\/td>/b + //,/^ <\/table>/b + //,/<\/table>/b + /