in reply to Using Mechanize to download a zip file?

Have you looked at what content you actually get? Maybe it is not what you think. Maybe it is yet another HTML page or something. Maybe open up the downloaded file in a text editor to see what it contains.

  • Comment on Re: Using Mechanize to download a zip file?

Replies are listed 'Best First'.
Re^2: Using Mechanize to download a zip file?
by PodMaster (Abbot) on Nov 07, 2005 at 14:19 UTC
    Maybe the module is broken :)? looks like a binmode is missing
    =head2 $mech->save_content( $filename ) Dumps the contents of C<< $mech->content >> into I<$filename>. I<$filename> will be overwritten. =cut sub save_content { my $self = shift; my $filename = shift; open( my $fh, ">", $filename ) or $self->die( "Unable to create $f +ilename: $!" ); print $fh $self->content; close $fh; }

    update: confirmed and reported

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      The module might be still broken; when I attempt to use the $mech->save_content method in this code:

      use strict; use warnings; use LWP::UserAgent; use WWW::Mechanize; use Win32::FileOp; #use Win32::FileOp qw(ShellExecute); # ShellExecute("http://finance.yahoo.com"); my $mech = WWW::Mechanize->new(); $mech->get("http://finance.yahoo.com"); my $filename = 'c:yahoo.html'; $mech->save_content ( $filename );


      I get the following message:
      Can't locate object method "save_content" via package "WWW::Mechanize" at Yahoo. pl line 13, <DATA> line 164.
        The module might be still broken;
        Not in that regard.
        http://search.cpan.org/src/PETDANCE/WWW-Mechanize-1.18/Changes
        1.05_02 Sat Oct  2 16:55:59 CDT 2004
            [ENHANCEMENTS]
            * Added the $mech->save_content( $filename ) function, so you
                  can dump stuff to files easily.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.