4chan download script
Thu, 24 Dec 2009 16:49 - Daniel - Other - Comments (10)
A few days ago 4chan changed their links and my old download script stopped working. Here is the updated version.
Continue reading
Tags: 4chan download shell bash wget grep
4chan download script
Sun, 31 Aug 2008 22:44 - Daniel - Other - Comments (18)
Downloads all the images from a 4chan image thread. I will probably regret downloading anything from 4chan, but that's not my problem.
Usage: 4chandl <4chan thread url>
Download the script
#!/bin/sh
if [ "$1" = "" ]; then
echo "Usage: `basename $0` <4chan thread url>"
exit 1
fi
echo "4chan downloader"
echo "Downloading untill canceled or 404'd"
LOC=$(echo "$1" | egrep -o '([0-9]*).html' | sed 's/\.html//g' )
echo "Downloading to $LOC"
if [ ! -d $LOC ]; then
mkdir $LOC
fi
cd $LOC
while [ "1" = "1" ]; do
TMP=`mktemp`
TMP2=`mktemp`
wget -O "$TMP" "$1"
if [ "$?" != "0" ]; then
rm $TMP $TMP2
exit 1
fi
egrep 'http://(img|cgi).4chan.org/[a-z0-9]+/src/(cb-nws/)?([0-9]*).(jpg|png|gif)' "$TMP" -o > "$TMP2"
cat "$TMP2" | sed 's!/cb-nws!!g' > "$TMP"
wget -nc -i $TMP
rm $TMP $TMP2
echo "Waiting 30 seconds befor next run"
sleep 30
done;
Tags: download 4chan shell bash wget grep
1