blob: 206a633be7e750b73e0a5233b6ba8c6d52dc8c91 (
plain)
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
29
30
31
32
33
34
35
|
#!/bin/sh
[ "$#" -lt 1 ] && { echo "savesite - save local copy of a website
USAGE: savesite <URL> [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"
|