Below is a shell script to retrieve and view comics from the web. To use
this script, you must
- Verify that you have the required executables display, sed and wget
installed (use e.g. whereis display), and write down the paths
to them.
- Save the text below (starting with #!/bin/sh) to a file.
- If necessary, edit the PATH= line in the script to include the
paths you found in part 1.
- Make the file executable by opening a command window and typing
chmod u+x filename.
- Run the file by typing ./filename. You should only see
lines beginning with "Viewing the URL ...", and then comics should appear
on your screen.
- Now edit the bottom section of the script to get the comics you want!
#!/bin/sh
# This script retrieves and displays selected comics from the web.
# It requires "display" (a part of ImageMagick) and "wget".
# It was written by Michael Miller (millermj@maple.lemoyne.edu),
# and was last edited on 03-Aug-2000.
# To add a new comic to the list below, navigate to a web page
# on which the comic appears, and denote that page's URL by "$3".
# Determine the URL of the comic image itself (in Netscape,
# right-click on the comic and choose "View Image"). Look for
# the ending of the comic's URL in the page source, write a regular
# expression which matches this ending, and denote this regular
# expression by "$2". Denote the beginning of the comic's URL
# by "$0" (so that the full URL of the comic matches $0$2). Now
# write a stanza below as
# URL="$0"`Extract 1 "$2" "$3"`
# View $URL
PATH="/bin:/usr/bin:/usr/bin/X11"
Extract(){
# "Extract $1 $2 $3" extracts the $1-th occurence of
# the regular expression $2 from the web page with URL $3.
wget $3 -q -O - | sed -n -e"s%^.*\($2\).*$%\1%p" | sed -n $1p
}
View(){
# "View $1" views the image given by the URL $1.
echo "Viewing the URL" $1
wget $1 -q -O - | display -display :0 &
}
#----------------------------------------------------------
#www.usrfriendly.org/cartoons
URL="http://www.userfriendly.org"`Extract 1 \
"/cartoons/archives/[0-9]*[a-z]*/xuf[0-9]*.gif" \
"http://userfriendly.org/static/"`
View $URL
#www.doonesbury.com/dailydose
URL="http://www.doonesbury.com"`Extract 1 \
"/dailydose/strips/[0-9]*/[0-9]*/db[0-9]*.gif" \
"http://www.doonesbury.com/dailydose/"`
View $URL
#www.msnbc.com/comics
for COMIC in bz #bizzarro
do
URL1="http://www.msnbc.com"`Extract 1 \
"/comics/daily.asp?sType=[0-9]&sImage=$COMIC[0-9]*&nDate=0" \
"http://www.msnbc.com/comics/"`
URL2="http://www.msnbc.com/comics/"`Extract 1 \
"comics/$COMIC[0-9]*.gif" $URL1`
View $URL2
done
#comics.com/comics
for COMIC in bc nonsequitur
do
URL="http://comics.com"`Extract 1 \
"/comics/$COMIC/archive/images/$COMIC[0-9]*.gif" \
"http://comics.com/comics/$COMIC/ab.html"`
View $URL
done
#comics.com/universal
for COMIC in boondocks closehome
do
URL="http://comics.com"`Extract 1 \
"/universal/$COMIC/archive/images/$COMIC[0-9]*.gif" \
"http://comics.com/universal/$COMIC/ab.html"`
View $URL
done