Last active
December 3, 2019 22:30
-
-
Save ssz66666/d54447c06404cd8dda387b4eabd2ce63 to your computer and use it in GitHub Desktop.
Download http directory with aria2c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z ${1+x} ]; then echo "URL must be specified!" && exit -1; fi | |
URL=$1 | |
ARGS="${@:2}" | |
PARENT=$(dirname $URL)/ | |
PARENT_ESCAPED="${PARENT//\//\\\/}" | |
wget -e robots=off -r -np -nH -nd --spider $ARGS $URL 2>&1 | \ | |
grep -o "$URL\([^/]*/\)*[^/?][^/]*$" | \ | |
sed 's/\(^'$PARENT_ESCAPED'\)\(.\+\)/\1\2\n\ \ out=\2/g' | \ | |
python3 -c'import urllib.parse,sys;[print(" out="+urllib.parse.unquote(s[6:]), end="") if s.startswith(" out=") else print(s, end="") for s in sys.stdin]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment