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

Yes, I have been there, but being a beginner I did not understand how to get that working.
Would it be possible to give a code that would work on the given example?

Replies are listed 'Best First'.
Re^3: LWP hit button to continue
by haj (Vicar) on Mar 23, 2021 at 16:07 UTC

    It's actually not that hard. I missed in your example HTML that the button is just "decoration" for the a element (which is missing a closing quote after https://something), so you don't need to "click" a button, you need to follow a link.

    Note that $url should be provided by someone.

    use WWW::Mechanize; $ua = WWW::Mechanize->new; my $response = $ua->get($url); my $next_response = $ua->follow_link(text_regex => qr/continue.../);

    I missed in your example that the button is just "decoration" for the a element (which is missing a closing quote after https://something), so you don't need to "click" a button, you need to follow a link.

Re^3: LWP hit button to continue
by hippo (Archbishop) on Mar 23, 2021 at 15:43 UTC
      Like I said: I know the next link, but I can only get there after hitting the button. Otherwise I am redirected back to the page I am already on.
        Otherwise I am redirected back to the page I am already on.

        New information. You will need to determine how the button affects things. If it changes the link through Javascript you will need to allow for that in your code. Conversely, if it manages state you will need to allow for that eg. by configuring a cookie jar. It might well do both.

        Since you've yet to give the URL of the page in question there's not much more to say at this point. Good luck with your endeavours.


        🦛

        People are telling you which tool to use to 'click' the button. Did you try any of these suggestions?