This commit is contained in:
Simon Vieille 2019-05-06 15:19:27 +02:00
commit 26dd4d25eb
Signed by: deblan
GPG Key ID: 03383D15A1D31745
2 changed files with 106 additions and 0 deletions

38
README.md Normal file
View File

@ -0,0 +1,38 @@
Website vacuum
==============
Interactive wrapper for `wget` and `httrack`.
## Installation
```
$ git clone https://gitnet.fr/deblan/website-vacuum.git
```
## Usage
```
$ ./bin/vacuum --help
Usage: ./bin/vacuum [url] [filters] [-h|--help|--wget|--httrack]
--wget Select GNU Wget
--httrack Select httrack to vacuum
-h,--help Show this help
Filters only work with httrack. `man httrack` to get help.
$ ./bin/vacuum
Example: https://www.example.com +assets.example.com/*
URL: https://www.example.com
Vacuum:
[1] httrack
[2] wget
> [1]
Command:
httrack https://www.example.com
[...]
```

68
bin/vacuum Executable file
View File

@ -0,0 +1,68 @@
#!/bin/sh
usage() {
printf "Usage: %s [url] [filters] [-h|--help|--wget|--httrack]\n\n" $0
printf " --wget Select GNU Wget\n"
printf " --httrack Select httrack to vacuum\n"
printf " -h,--help Show this help\n\n"
printf "Filters only work with httrack. \`man httrack\` to get help.\n"
}
TOOL=
URL=
for i in $@; do
if [ "$i" = "-h" -o "$i" = "--help" ]; then
usage
exit 0
elif [ "$i" != "--httrack" -a "$i" != "--wget" ]; then
URL="$URL $i"
elif [ "$i" = "--httrack" ]; then
TOOL=httrack
elif [ "$i" = "--wget" ]; then
TOOL=wget
fi
done
if [ -z "$URL" ]; then
printf "Example: https://www.example.com +assets.example.com/*\n\n"
while test -z "$URL"; do
printf "URL: "
read URL
done
fi
if [ -z "$TOOL" ]; then
while test -z "$TOOL"; do
printf ""
printf "Vacuum:\n"
printf " [1] httrack\n"
printf " [2] wget\n"
printf "> [1] "
read TOOL
if [ -z "$TOOL" ]; then
TOOL=1
fi
if [ "$TOOL" = "1" -o "$TOOL" = "httrack" ]; then
TOOL=httrack
elif [ "$TOOL" = "2" -o "$TOOL" = "wget" ]; then
TOOL=wget
else
TOOL=
fi
done
fi
if [ "$TOOL" = "httrack" ]; then
printf "\nCommand:\n\n httrack %s\n\n" "$URL"
httrack $URL
elif [ "$TOOL" = "wget" ]; then
printf "\nCommand:\n\n wget --progress=bar -E -r -k -np --no-check-certificate --user-agent=Firefox \"%s\"\n\n" $URL
wget --progress=bar -E -r -k -np --no-check-certificate --user-agent=Firefox $URL
fi