Skip to content

Instantly share code, notes, and snippets.

@lanky
Forked from felipetavares/userfriendly.sh
Created June 14, 2023 13:57
Show Gist options
  • Save lanky/37162138057e8974cf57eaec483da663 to your computer and use it in GitHub Desktop.
Save lanky/37162138057e8974cf57eaec483da663 to your computer and use it in GitHub Desktop.
Download all the User Friendly comics!
#!/bin/bash
years="1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015"
months1="01 02 03 04 05 06 07 08 09 10 11 12"
months2="11 12"
n=1
for y in $years
do
if [ $y = "1997" ]; then
months=$months2
else
months=$months1
fi
for m in $months
do
d=1
while [ $d -lt 31 ];
do
rd=""
if [ $d -lt 10 ]; then
rd="0$d"
else
rd="$d"
fi
echo -ne Searching number $n\\r
url="http://ars.userfriendly.org/cartoons/?id=${y}${m}${rd}"
wget $url -O tmp.html 2> /dev/null
image=`cat tmp.html | grep -o "http://www.userfriendly.org/cartoons/archives/.\+\.gif"`
if [ "$image" != "" ]; then
if [ ! -f "${n}.png" ]; then
echo -ne Downloading number $n\\r
wget $image -O "${n}.gif" 2> /dev/null
convert -verbose -coalesce "${n}.gif" "${n}.png"
if [ -f tmp.html ]; then
rm tmp.html
fi
rm *.gif
fi
let "n++"
fi
let "d++"
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment