On Sun, 19 Feb 2012 14:51:57 -0600 Mike Flannigan <[email protected]> wrote:
> > I've got a question for you guys. Maybe an > easy question. > > I want to download the file '02251_new_1923-0059.zip' > from the website: > https://spatialdata.iu.edu/DOQQS/state/sanborn/public/tif/1923/ > > The script below works (I think), but it outputs the > file to STDout. I haven't tried yet, but I gather if > I print this to a filehandle I will not get the binary > zip file, but a text file instead. > > What is the proper way to download the file to a binary > zip file using LWP::UserAgent and the Crypt-SSLeay module > I just obtained from University of Winnipeg? > http://johnbokma.com/perl/https.html > > > > Mike > > > > use warnings; > use strict; > use LWP::UserAgent; > > my $url = > 'https://spatialdata.iu.edu/DOQQS/state/sanborn/public/tif/1923/02251_new_1923-0059.zip'; > > my $ua = LWP::UserAgent->new; > my $response = $ua->get( $url ); > > $response->is_success or die "Failed to GET '$url': ", > $response->status_line; > > print $response->as_string; LWP::UserAgent has a mirror() method that downloads directly to a file. G. Wade -- All things are possible, given enough time and caffeine. -- Danny Hoover _______________________________________________ Houston mailing list [email protected] http://mail.pm.org/mailman/listinfo/houston Website: http://houston.pm.org/
