Skip to content

Instantly share code, notes, and snippets.

@KittyKatt
Last active December 18, 2015 21:29
Show Gist options
  • Save KittyKatt/5847382 to your computer and use it in GitHub Desktop.
Save KittyKatt/5847382 to your computer and use it in GitHub Desktop.
4chan Thread Archiver
#!/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