#!/usr/bin/perl # hash-bang / she-bang / sh-bang 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 = 'www'; $pass = 'zzzz'; $url = "https://www.instagram.com/accounts/login/?source=auth_switcher&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); if ($mech->success()) { $mech->sleep(1); # waiting for load site $mech->form_number(1); $mech->value( username => $user ); $mech->value( password => $pass ); $mech->eval_in_page(<<'JS'); var cls = document.getElementsByClassName('_0mzm- sqdOP L3NKy '); Array.prototype.forEach.call(cls, (item) => item.removeAttribute('disabled')); JS $mech->click({intrapage => 1, text => 'Log In', single => 1 }); $mech->sleep(2); print $mech->content; } else { print "Not connect to: ".$url."\r\n"; } return 0; } main ();