How about <http://search.cpan.org/dist/libwww-perl/bin/lwp-download>
John David M. Funk wrote: > > Hello List, > > I have a perl script that connects to a website using LWP and pulls > down a csv & pdf file from the URL. Both of these a basically ascii > text files. This has been working fine for quite some time now. Just > recently the files are winzip files “.zip”. So when I try to d/l them > I get a hex file with the HTTP headers included. > > How do I remove the headers or is there a better way to d/l a binary file? > > Code snippet…… > > use HTTP::Cookies; > > use IO::Socket::SSL; > > $ua = LWP::UserAgent->new; > > $ua->agent("" . $ua->agent); > > $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt",autosave > => 1)); > > &mesg("-------------------------------------------------------------------------------------\n\n"); > > &mesg("Calling $url..........................\n"); > > $response = $ua->get("$url"); > > @result = split(/\n/,$response->as_string()); > > foreach $line (@result) { > > if ($line =~ /nowrap/ && $line =~ /\-csv\.zip\?/) { > > print "$line\n"; > > $line =~ /\<td nowrap\>\<a href\=\"\/(.*)\" class\=\'buttonText\'\>/; > > $url1=$1; > > $url1 =~ /ime\/(.*)\?/; > > $csvfile=$1; > > &mesg("-------------------------------------------------------------------------------------\n"); > > &mesg("Filename->$csvfile<-\nURL->$baseurl/$url1<-\n"); > > } > > if ($line =~ /nowrap/ && $line =~ /\-pdf\.zip\?/) { > > $line =~ /\<td nowrap\>\<a href\=\"\/(.*)\" class\=\'buttonText\'\>/; > > $url2=$1; > > $url2 =~ /ime\/(.*)\?/; > > $pdffile=$1; > > &mesg("-------------------------------------------------------------------------------------\n"); > > &mesg("Filename->$pdffile<-\nURL->$baseurl/$url2<-\n"); > > } > > } > > if ($url1 eq "" || $csvfile eq "" || $url2 eq "" || $pdffile eq "") { > > &mesg("Something went wrong.................................\n"); > > &mesg("URL1 ->$url1<-\nCSVFILE ->$csvfile<-\nURL2 ->$url2<-\nPDFFILE > ->$pdffile<-\n"); > > &mesg("-------------------------------------------------------------------------------------\n"); > > &write_html; > > &mesg("emailing the error notification to > $group........................."); > > &send_email("UPS File Errors","Possibly the wrong > URL?\nURL->$url<-\nSee attached.....\n",$group,$LOGDIR,"html.log"); > > &mesg("Complete..\n"); > > &mesg("\n########## Finished $tdate ##########\n"); > > &write_log if $#LOG >=0; > > exit; > > } > > &mesg("-------------------------------------------------------------------------------------\n"); > > &mesg("Calling $baseurl/$url1..........................\n"); > > &mesg("Getting File $csvfile..........................\n"); > > $response1 = $ua->get("$baseurl/$url1"); > > $file1=$response1->as_string(); > > &mesg("Writing $csvfile to local disk.........................."); > > open (CSVFIL, ">$basedir/$csvfile") || warn &mesg("Can't open > $basedir/$csvfile: $!\n"); > > print CSVFIL "$file1\n"; > > close(CSVFIL); > > &mesg("Complete..\n"); > > &write_log if $#LOG >=0; > > $file1=""; > > &mesg("Calling $baseurl/$url2..........................\n"); > > &mesg("Getting File $pdffile..........................\n"); > > $response2 = $ua->get("$baseurl/$url2"); > > $file2 = split(/\n/,$response2->as_string()); > > &mesg("Writing $pdffile to local disk.........................."); > > open (PDFFIL, ">$basedir/$pdffile") || &mesg("Can't open > $basedir/$pdffile: $!\n"); > > print PDFFIL "$file2\n"; > > close(PDFFIL); > > &mesg("Complete..\n"); > > $file2=””; > > my($stop) = time(); > > $responsetime = $stop - $start; > > &write_log if $#LOG >=0; > > } > > TIA, > > David M. Funk > President/CEO > > Tivoli Certified Enterprise Consultant > /Specializing in Network and Systems Management Solutions/ > > Trinity Solutions > 604 Cassandra Dr. > Cranberry Twp., PA 16066 > > Phone: 724-316-0721 > Fax: 724-772-7889 > email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > www: http://www.trinityITsolutions.com > > ------------------------------------------------------------------------ > > _______________________________________________ > Perl-Win32-Users mailing list > Perl-Win32-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs