-
-
Save KittyKatt/5847382 to your computer and use it in GitHub Desktop.
4chan Thread Archiver
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
#!/usr/bin/env bash | |
# 4chan Thread Archiver | |
# requires: wget | |
# Settings | |
archivefolder=/srv/http/kittykatt.us/served.kittykatt.us/projects/4chanarchive | |
archivesite='http://served.kittykatt.us/projects/4chanarchive' | |
thread="$1" | |
threadreal=$(echo "$thread" | sed 's/http:\/\///') | |
threadnum=$(echo "$threadreal" | cut -f 4 -d /) | |
cd "$archivefolder" | |
mkdir "$threadnum" | |
[[ ! -d "$threadnum" ]] && echo 'Error creating directory!' && exit 1 | |
cd "${threadnum}" | |
echo -n "Getting thread" | |
wget -e robots=off -E -nd -N -np -r -k -H -Dimages.4chan.org,thumbs.4chan.org "" ${thread} 2>/dev/null & | |
while ps | grep $! &>/dev/null; do | |
echo -n "." | |
sleep 2 | |
done | |
if [[ -f ${threadnum}.html ]]; then | |
echo 'done!' | |
mv ${threadnum}.html index.html | |
else | |
echo "error retrieving thread!" | |
exit 1 | |
fi | |
echo "Your thread has been saved to ${archivefolder}/${threadnum}/index.html!" | |
echo "It can be viewed by pointing your browser to ${archivesite}/${threadnum}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment