Created
December 1, 2009 16:28
-
-
Save cbilson/246406 to your computer and use it in GitHub Desktop.
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
#------------------------------------------------------------------------------- | |
# Downloads photos from National Geographic's Photo Contest | |
#------------------------------------------------------------------------------- | |
param($res = '1280', $year = '2008') | |
$client = New-Object System.Net.WebClient | |
$client.Headers.Add('User-agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)') | |
$prefixes = @{ | |
'2008' = @('1107', '1103', '1027', '1020', '1014', '1006', '0929', '0922', | |
'0915', '0908', '0901', '0825', '0818', '0811'); | |
'2009' = @('1109', '1102', '1026', '1019', '1013', '1005', '0928', '0921', | |
'0914', '0907', '0831', '0824', '0817') | |
} | |
function Get-ImageFromNatGeo($name) { | |
if ($year -eq '2009') { | |
$uri = New-Object Uri("http://ngm.nationalgeographic.com/photo-contest/2009/img/wallpaper/$name") | |
} else { | |
$uri = New-Object Uri("http://ngm.nationalgeographic.com/photo-contest/img/wallpaper/$name") | |
} | |
"Downloading $uri to $name..." | |
$client.DownloadFile($uri, $name) | |
} | |
foreach ($i in 1..26) { | |
foreach ($prefix in $prefixes[$year]) { | |
$name = '{0}wallpaper-{1}_{2}.jpg' -f $prefix, $i, $res | |
Get-ImageFromNatGeo $name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment