5 July 2012

PhD Comics Downloader

If you like PhD Comics, try this.

Put the following Unix/Linux Bash script into a file named "phdcomics-download.sh".

#! /bin/sh

curl http://www.phdcomics.com/comics/archive.php?comicid=[${1-1}-${2-1420}] 2> /dev/null | \
    perl -wnl -e 'print $1 if m|(http://.*?/phd[^/]*?\.gif)|' | \
    xargs -n 1 wget -nc -nd -P comics

Make it executable

chmod +x phdcomics-download.sh
and execute it.
./phdcomics-download.sh
Wait a while and see what is inside the newly created directory comics.

Optionally, you can put two numbers after the script to download only a range of the stripes, like this.

./phdcomics-download.sh 1 1420  # 1420 is the latest one as of today

Enjoy, and thank the authors.