From 5c916d69d457101326803eb076a746060e3618cf Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Thu, 21 Nov 2024 13:30:52 +0530 Subject: Moved from github --- .local/bin/web/savesite | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 .local/bin/web/savesite (limited to '.local/bin/web/savesite') diff --git a/.local/bin/web/savesite b/.local/bin/web/savesite new file mode 100755 index 0000000..206a633 --- /dev/null +++ b/.local/bin/web/savesite @@ -0,0 +1,35 @@ +#!/bin/sh + +[ "$#" -lt 1 ] && { echo "savesite - save local copy of a website +USAGE: savesite [DEST_DIR]"; exit 1; } + +url="$1" +site="${2:-"$(echo "$url" | sed 's|\(https\?://\)\?\([A-Za-z0-9.-]*\)/.*|\2|')"}" +WGETLOGS="${3:-.logs/$site.log}" +started="$(date)" + +touch "$WGETLOGS" || exit +printf ":: Downloading site: %s\n" "$site" +printf ":: Logging to: %s\n" "$WGETLOGS" + +{ + setsid wget \ + --continue \ + --recursive \ + --no-clobber \ + --page-requisites \ + --html-extension \ + --convert-links \ + --restrict-file-names=windows \ + --domains "$site" \ + --no-parent \ + --output-file "$WGETLOGS" \ + "$url" + + [ -n "$DISPLAY" ] && notify-send "savesite: finished downloading" "$site" + printf "%s\n" ":: Finished downloading site: $site" \ + ":: Started at: $started" \ + ":: Finished at: $(date)" >> "$WGETLOGS" +} & + +tail -f "$WGETLOGS" -- cgit v1.2.3