Skip to content

Instantly share code, notes, and snippets.

@lukevers
Created November 14, 2012 21:53
Show Gist options
  • Save lukevers/4075094 to your computer and use it in GitHub Desktop.
Save lukevers/4075094 to your computer and use it in GitHub Desktop.
xkcd.sh
#!/bin/bash
# Create a folder for xkcd
mkdir xkcd
echo 'Created directory "xkcd"'
# Make sure to cd into the folder
cd xkcd
# Loop through all of them
for i in `seq 1 1`
do
echo 'Downloading xkcd comic '$i
# Create a folder for $i and then wget the comic $i
mkdir $i
wget -k -O $i/index.html http://xkcd.com/$i/
# Make sure to cd into the folder
cd $i
# Parse out the image URL and get the the image
LINE=$(grep 'Image URL (for hotlinking/embedding):' index.html)
URL=${LINE:38}
NAME=${URL:28}
wget $URL
# Somehow edit the fucking file to have the correct url
# it should have $NAME instead of $URL
# Make sure to go back or it'll be a hugeeee folder
cd ..
echo 'Completed xkcd comic '$i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment