I have found this code online (Source)to download bing images.
This perl script download the todays Bing wallpaper image, how I can change it to test all possible dates backwards? It dosn't matter when it stops because I'm gonna stop manually.
I tried some options but I don't know perl and it's getting a little frustrating.
Thanks a lot!
#!/usr/bin/perl
$\="\n";
use strict;
use warnings;
use Data::Dumper;
use LWP::Simple;
use JSON;
use POSIX qw/strftime/;
my $base_url = "http://www.bing.com/";
my $json_url = "http://www.bing.com/HPImageArchive.aspx?format=js&n=1&mkt=en-US";
my $output_dir = "C:\\Downloads\\Wallpaper";
my $content = get($json_url)
or die "Failed to retrieve $json_url! $! $@";
my $json = from_json($content)
or die "Failed to parse json response! $! $@";
my $image_url = $base_url . $json->{images}[0]->{url};
print "Today's Image: $image_url";
my $date = strftime('%Y_%m_%d',localtime);
my $filename = "$output_dir\\$date.jpg";
print $filename;
my $status = getstore($image_url,$filename);
if($status == 200)
{
print "HTTP Response OK.";
my $size = -s $filename;
if($size > 0)
{
print "Retrieved $size bytes.";
}
elsif($size == 0)
{
print "Seems we have retrieved a zero-byte image.";
}
}
else
{
print "HTTP Response: $status";
}```