#!/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_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); $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 ();