save-web-page.sh 655 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#! /bin/sh

set -x

target="$HOME/mnt/query-fs/backing-store/saved-web/$(date +%Y/%m/%d/%H-%M-%S/)"
mkdir -p "$target"
target="$(mktemp -d -p "$target")"
basename="$( ( echo "$1"; date +%Y%m%d-%H%M%S; ) | sha256sum | sed -e 's/ .*//' )"

cd "$(dirname "$0")"

url="$1"
if ! echo "$url" | grep -E '^[a-z]+:' > /dev/null; then
        url="https://$url"
fi

url="${url//\"/%22}"
url="${url//\\/%5c}"

./thoughtful-theridion.bin --non-interactive --eval "(thoughtful-theridion::save-web-page \"$url\" \"$target\" \"$basename\" $2)"

shift; shift

if test -n "$1"; then 
        "$@" "$target/$basename.html.txt"
else
        echo "$target/$basename.html"
fi