in reply to LWP hit button to continue

To follow the link you will need to parse it out of the returned content. See the answers to How do I parse links out of a web page for some guidance in that task.


🦛

Replies are listed 'Best First'.
Re^2: LWP hit button to continue
by Anonymous Monk on Mar 23, 2021 at 15:35 UTC
    The link was parsed as seen in the given html: "https://something".
    Problem is hitting the button: to agree to continue.

      Quick and dirty example using WWW::Mechanize to get a fake page, click a button, print the title of the next page:

      #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get('https://derpderpderp.com'); # fake URL $mech->click_button( number => 2 ) # click the second button on fake p +age #do whatever you want with the next page, e.g. print the title print $mech->title;
        Thanks a lot, that's what I am looking for. However now I get an error:
        <h1>Software error:</h1> <pre>Can't call method &quot;click&quot; on an undefined value at C:/P +erl/site/lib/WWW/Mechanize.pm line 982, &lt;STDIN&gt; line 1. </pre> <p> For help, please send mail to this site's webmaster, giving this error + message and the time and date of the error. </p>

        perl:
        use WWW::Mechanize;
        my $ua = WWW::Mechanize->new();
        $ua->get($url); # url page with button
        $ua->click_button( number => 1 ); # there is only one button
        print $ua->title;
        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."
        I am afraid giving the link would not be apropriate for this site :-) I thought there was a solution in general terms, so if that is not possible I will leave it at this...
        Apologies, I overlooked that.
        Output after having to change ' to "
        1.89SCALAR(0x7db2d4)