dhanu has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to write a perl script using WWW:::Mechanize, to download a dictionary file from a server.
The file is a zip file. The program given below (error checks have been purposely removed),
This program runs without any errors/warnings,
and i can see the file downloaded in the specified location.
The download is supposed to get me a zip file,
but when i open the file using winzip/winrar i get an error.
When i download it as .zip, opening with winzip gives this error:"filename: start of central directory not found; Zip file corrupt. Possible cause:file transfer error."
When i download it as .tar, winzip gives this error:"Error reading header after processing 0 entries."
Winrar gives this error "<filename>: Unexpected end of archive".
The server is on a Free BSD machine, my program is on running on Windows(Active Perl 5.8.7)
I'm surely missing something here, and cannot find a way out of this problem! :(
I had sent this message to perl-beginners/ libwww lists earlier but no response.
Hence posting again :)
Please help!
Best regards,
Dhanashri
==========================
============================#!/usr/bin/perl -w use strict; use WWW::Mechanize; my $login = "admin"; my $password = "pass"; my $url = "http://abc.xyz.com"; my $mech = WWW::Mechanize->new(); $mech->get($url); #Log in print "\n\n\n\nLogging in.... \n\n\n\n"; $mech->submit_form( form_number => 1, fields => { user => $login, password => $password }, ); #Navigate to the download page $mech->follow ( 'Download' ); if ($mech->success) { #this page has only one form with the "download" button. #Download is for a zip file. $mech->click(); if ($mech->success) { my $filename = 'E:\Dhanashri\down.zip'; $mech->save_content ( $filename ); print "\nFile Downloaded!\n\n"; } else { print "\nDownload Failed!\n"; } } print "Logging out...\n"; $mech->follow ( 'logout' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Mechanize to download a zip file?
by Corion (Patriarch) on Nov 07, 2005 at 11:53 UTC | |
by PodMaster (Abbot) on Nov 07, 2005 at 14:19 UTC | |
by Scott7477 (Chaplain) on May 10, 2006 at 23:27 UTC | |
by PodMaster (Abbot) on May 13, 2006 at 03:13 UTC | |
|
Re: Using Mechanize to download a zip file?
by polettix (Vicar) on Nov 07, 2005 at 11:56 UTC | |
|
Re: Using Mechanize to download a zip file?
by spatterson (Pilgrim) on Nov 07, 2005 at 12:22 UTC |