in reply to Re^3: LWP hit button to continue
in thread LWP hit button to continue

Here is a simple example site:

https://hungergj.home.xs4all.nl/test.htm

This is the perl program "test button.pl":

#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $ua = WWW::Mechanize->new(); $ua->get("https:\/\/hungergj.home.xs4all.nl\/test.htm"); $ua->click_button( number => 1 ); print $ua->title; print "=================\n";; $_=<STDIN>;
The output is this time:
"click_button: No form has been selected at test button.pl line 12."

Replies are listed 'Best First'.
Re^5: LWP hit button to continue
by hippo (Archbishop) on Mar 23, 2021 at 18:56 UTC

    click_button says "Has the effect of clicking a button on the current form by specifying its attributes". The page at that URL doesn't have a form, so you get the expected error message.

    Just use the links instead as previously explained:

    #!/usr/bin/env perl use strict; use warnings; use WWW::Mechanize; my $ua = WWW::Mechanize->new(); $ua->get ('https://hungergj.home.xs4all.nl/test.htm'); my @links = $ua->links(); print $ua->get ($links[0]->url)->decoded_content;

    🦛