Last active
December 29, 2015 09:39
-
-
Save sblask/7652174 to your computer and use it in GitHub Desktop.
Download all wallpapers from national geographic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
root=http://ngm.nationalgeographic.com | |
months=(january february march april may june july august september october november december) | |
download() { | |
year=$1 | |
from=$2 | |
to=$3 | |
for month in $(seq $from $to) | |
do | |
folder=${year}-`printf %02d $month` | |
mkdir ${folder} | |
curl ${root}/wallpaper/${year}/${months[month - 1]}-ngm-wallpaper | | |
grep "Download wallpaper" | | |
awk 'BEGIN {FS="\""} {print $2}' | | |
while read url | |
do | |
wget ${root}${url} --directory-prefix ${folder} | |
done | |
done | |
} | |
download 2011 10 12 | |
download 2012 1 12 | |
download 2013 1 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment