damian1 has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have problem with module WWW::Mechanize::Chrome

I try create program to log in on Instagram. I try all capabilities but don’t log in. Log In form is dynamic in javascript.

I suppose that it is about disable status button „Log In”, but i correct complement two input fields but Log In still disabled status.What to do in this situation?

Please see my code:

#!/usr/bin/perl use strict; use warnings; use Log::Log4perl ':easy'; use WWW::Mechanize::Chrome; use open ':std', ':encoding(UTF-8)'; sub main () { my $mech; my $res; my $url; my $cookies; my $username; my $password; my $user; my $pass; my @formlist; $user = "zzz"; $pass = "www"; $url = "https://www.instagram.com/accounts/login/?source=auth_swit +cher&hl=en"; $mech = WWW::Mechanize::Chrome->new( launch_exe => 'chromium', launch_arg => ["--no-sandbox", "--disable-setuid-sandbox", + "--remote-debugging-port=9222", "--headless"], ); $mech->allow( javascript => 1 ); $mech->get($url); $mech->sleep(5); # waiting for load site $mech->form_number(1); $username = $mech->xpath('//input[@type="text"]', single => 1 ); $username->set_attribute('value', "$user"); $password = $mech->xpath('//input[@type="password"]', single => 1 +); $password->set_attribute('value', "$pass"); $mech->click({ text => 'Log In', single => 1 }); # for headless print $mech->content; return 0; } main ();

Replies are listed 'Best First'.
Re: WWW::Mechanize::Chrome Instagram
by jcb (Parson) on Sep 01, 2019 at 23:13 UTC

    I will guess a timing problem, where you are "clicking" the button before the page JS has had a chance to respond to the form being filled in, or an event problem, where the page JS is expecting to see "key press" events as the form is filled in and your DOM manipulations are invisible to it.

Re: WWW::Mechanize::Chrome Instagram
by nysus (Parson) on Sep 02, 2019 at 16:51 UTC

      Can you show me Your "hacked" code?

        I don't remember but my code is in the comment there in the previous link. But the original code might have changed. I modified the _mightNavigate sub, line 1585: https://github.com/Corion/WWW-Mechanize-Chrome/blob/d94c8f43a8c72efc994695e7c075dbc849b2c1e4/lib/WWW/Mechanize/Chrome.pm

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks