in reply to Re: Weather RSS image
in thread Weather RSS image

(above caveats on harvesting the images) but just for sake of example here's a bash one liner:
for n in `seq 0 99` ; do wget http://us.i1.yimg.com/us.yimg.com/i/us +/we/52/$n.gif ; done
Also, instead of get() and open/print/close, can just use LWP::Simple's getstore() method:
use LWP::Simple; use strict; use warnings; for my $index (0 .. 99) {# actually 47 is the last index print "downloading $index.gif\n"; my $res = getstore("http://us.i1.yimg.com/us.yimg.com/i/us/we/52/$ +index.gif", "weather$index.gif"); }
or just:
perl -MLWP::Simple -e 'getstore("http://us.i1.yimg.com/us.yimg.com/i/u +s/we/52/$_.gif", "weather$_.gif") for 0 .. 99'

Replies are listed 'Best First'.
Re^3: Weather RSS image
by pg (Canon) on Nov 09, 2005 at 22:07 UTC

    Unfortunately your Perl code does not work. I called binmode() in my code for a reason. Your code would be fine with html files, but with images, it does not work.

    If you test your code, you will see that some images are broken (or cannot be recognized as the right format).

      Huh? getstore calls binmode:

      elsif (!ref($arg)) { # filename open(OUT, ">$arg") or return HTTP::Response->new(&HTTP::Status::RC_INTERNAL_SERV +ER_ERROR, "Cannot write to '$arg': $!"); binmode(OUT);

      source

      Call stack:

      • LWP::Protocol::collect
      • LWP::Protocol::http::request
      • LWP::UserAgent::send_request
      • LWP::UserAgent::simple_request
      • LWP::UserAgent::request
      • LWP::Simple::getstore

      It's not a recent addition either. The version of libwww-perl packaged with ActiveState Perl v5.6.1 does the same thing.

      I've successfully downloaded all the images on a Windows system (where binmode would matter) using getstore and ActiveState Perl v5.6.1.

      It does work (well, i had to do s/Sumple/Simple/ first ;) ) -- and running file weather* afterward shows "GIF image data, version 89a, 52 x 52" for all of them ...
      which images did you see as broken? Did you try re-downloading them?