-
Notifications
You must be signed in to change notification settings - Fork 0
/
scraper
executable file
·39 lines (34 loc) · 1.04 KB
/
scraper
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
36
37
38
39
#!/bin/sh
# Simple general purpose scraper, written in POSIX shell using basic tools
# Licensed under the Unlicense, please see LICENSE for more information
# Depends on wget
HELP="Usage: scraper [url] [-hvsf]
Simple general purpose scraper using basic commandline tools
-h Displays help info
-v Displays version info
-s [location] Changes save location (default: ~/Downloads)
-f [foo,bar] Changes file formats (default: a lot of them)"
VERSION="v1.2"
save="$HOME/Downloads/"
formats="mp4,m4v,webm,png,jpg,jpeg,gif"
while getopts ":hvs:f:" opt; do
case "$opt" in
"h") echo "$HELP"
exit 1;;
"v") echo "$VERSION"
exit 1;;
"s") save=$OPTARG;;
"f") formats=$OPTARG;;
*) echo "$HELP"
exit 1;;
esac
done
for i in "$@"; do
case $i in
"http"*|*".com"*|*".org"*|*"www"*) url=$i;;
*);;
esac
done
[ -z $url ] && echo "$HELP" && exit 1
[ -z $save ] && echo "$HELP" && exit 1
wget -H -nd -r -l 1 -P $save -A $formats -e robots=off $url