in reply to Re: Using Mechanize to click a button
in thread Using Mechanize to click a button

Sorry, here it is

my $mech = WWW::Mechanize->new(); print "Accessing $url\n"; $mech->get($url); print "Downloading the file..."; $mech->click_button (value => "TAB"); $mech->save_content( $full_path ); print "Done.\n";
Thanks! output:
Accessing http://spiedigitallibrary.org/ebooks/spies/kbart?isAuthorize +d=no Downloading the file...Can't call method "header" on an undefined valu +e at /exlibris/sfx_ver/app/perl-5.10.1/lib/site_perl/5.10.1/WWW/Mecha +nize.pm line 2381.
If I hash out the code related to the button the main mage is saved without problem.

Replies are listed 'Best First'.
Re^3: Using Mechanize to click a button
by moritz (Cardinal) on Mar 17, 2011 at 12:41 UTC

    The WWW::Mechanize documentation says that click_button works on the "current Form", which might be the source of your problem. There's a search form before the form you are interested in.

    So you might need to invest some effort into selecting the right form.

      Thank you moritz! I totally missed this.