Re: start of central directory not found, Corrupt zip file
- From: "DJ Stunks" <DJStunks@xxxxxxxxx>
- Date: 30 May 2006 18:28:24 -0700
TheAnswer1313 wrote:
hi using perl i tried to download a couple of zip files. They worked
fine but when i went to unzip them, i got that error msg. I have
noticed that when i download the files manually, they are slightly
smaller then when i download them with the script. If anyone can help
me around this issue, it would be great appreciated.
#!/usr/bin/perl -w
use FileHandle;
use LWP::UserAgent;
$ua = LWP::UserAgent ->new;
$baseurl = "http://www.retro***.org/";
$league = 'ml';
for ($year = 00; $year <= 05; $year++) {
my $filename = '200' . $year . $league . '.zip';
my $url = $baseurl . '200' . $year . '/200' . $year . $league .
'.zip';
my $req = HTTP::Request ->new(GET => $url);
my $res = $ua ->request($req);
print STDERR "fetching $filename\n";
if ($res ->is_success) {
my $fh = new FileHandle ">$filename";
if (defined $fh) {
print $fh $res ->content;
$fh ->close;
} else {
print STDERR "could not open file $filename: $!\n";
}
}
else {
print STDERR $res ->status_line, "\n";
}
}
my guess (and it's only a guess) is that you need to binmode() your
filehandle as you write out the data you downloaded.
however, there's probably a better module for you to use to download a
file. LWP::Simple maybe...
HTH,
-jp
.
- Follow-Ups:
- Re: start of central directory not found, Corrupt zip file
- From: TheAnswer1313
- Re: start of central directory not found, Corrupt zip file
- References:
- start of central directory not found, Corrupt zip file
- From: TheAnswer1313
- start of central directory not found, Corrupt zip file
- Prev by Date: Re: year not returned by Time::localtime
- Next by Date: Re: start of central directory not found, Corrupt zip file
- Previous by thread: start of central directory not found, Corrupt zip file
- Next by thread: Re: start of central directory not found, Corrupt zip file
- Index(es):